Subscribe Bookmark RSS Feed

varying behavior of Summary in JSL?

hardner

Community Trekker

Joined:

Nov 13, 2012

Can someone explain this?

dt=newtable("test", Add Rows( 8 ),
New Column( "A",Character,Nominal,Set Selected,
Set Values({"apple", "apple", "apple", "apple", "pear", "pear", "pear", "pear"})
),
New Column( "B",Character,Nominal,
Set Values({"red", "green", "red", "yellow", "yellow", "yellow", "pink", "pink"})
)

);

//first way - this summarizes everything, not just apple rows

dtsummary1=dt<<summary(group(:B),where(:A=="apple"));

//second way - this summarizes only apple rows like I wanted

currentdatatable(dt);

dtsummary2=summary(group(:B),where(:A=="apple"));

I can just use the second way but I don't understand this behavior. Why doesn't Where work the same?  Is there some smarter way to get the B values for just apple rows?

2 REPLIES
chungwei

Staff

Joined:

Jun 23, 2011

Note that summary itself does not parse the where clause.

In the first case, you are sending the summary message to the data table dt.

Summary resolves what it understands, which in this case is the grouping column.

The second case behaves like a platform. The platform resolves the data table and sends the message to it.

In this case, the data table is the subset where :A=="apple".

hardner

Community Trekker

Joined:

Nov 13, 2012

Interesting.  That makes me wonder if there are other commands that I can make "behave like a platform" by not sending them as messages.  And what different behaviors that would make possible. The platforms (like FitYbyX say) seem to behave the same whether sent as a message to a table or not but maybe there are also differences there?  If I say dt<<Bivariate(..) am I making a platform behave as a command in some way that might make any difference?  ( I do that all the time as it seems a less cumbersome way to make sure I'm talking to the correct table).