cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
EMJohnson-Kueny
Level III

The tallest girl in Big Class is 66 inches, but who is she?

I'm going to use the Big Class data as the example, but my data set is about an order of magnitude larger, and my co-worker's data set is even larger.

 

There are several ways I can find out the maximum height of girls vs boys in the Big Class data set, but how can I keep the name column attached? I can make a table using Tabulate, but I can't add a name column because it just lists all the names. I could make a scatter plot and pick out the tallest and write it down, but our real data set is too big for that. I can almost get it using the SQLQuery builder, if only if it would let me uncheck "Group By/Name", but as is I get exactly what I got from Tabulate.

Any method (besides the graph!) would be helpful!

 

Thanks in advance.

5 REPLIES 5
txnelson
Super User

Re: The tallest girl in Big Class is 66 inches, but who is she?

Names Default To Here( 1 );
dt = Open( "$sample_data\big class.jmp" );
Show( :name[((dt << get rows where( :sex == "F" & :height == Col Max( If( :sex == "F", :height, . ) ) ))[1])] );
Jim
EMJohnson-Kueny
Level III

Re: The tallest girl in Big Class is 66 inches, but who is she?

Thanks for the quick reply!
Two things:
Firstly, all this is doing for me is opening the file.
Secondly, What if I want to know the tallest boy at the same time? We've got several "classes" and we need to know "tallest girl and boy" in each.
txnelson
Super User

Re: The tallest girl in Big Class is 66 inches, but who is she?

Here is an expansion on the code to handle both Males and Females

Names Default To Here( 1 );
dt = Open( "$sample_data\big class.jmp" );
Show(
	:name[((dt << get rows where( :sex == "F" & :height == Col Max( If( :sex == "F", :height, . ) ) ))[1])],
	:name[((dt << get rows where( :sex == "M" & :height == Col Max( If( :sex == "M", :height, . ) ) ))[1])]
);

The Show() function writes the results to the log

:name[(dt << get rows where(:sex == "F" & :height == Col Max(If(:sex == "F", :height, .))))[1]] = "JACLYN";
:name[(dt << get rows where(:sex == "M" & :height == Col Max(If(:sex == "M", :height, .))))[1]] = "LAWRENCE";

 The formula returns the row where the maximum height for the male or female is located, so all column values for that row are available for query.  This query can surface almost display or action you need.  I chose just writing it to the log, to illustrate that the query results in the correct answer.

Jim
EMJohnson-Kueny
Level III

Re: The tallest girl in Big Class is 66 inches, but who is she?

It's been literally years, but I figured out a way to do it without code, and with either Big Class or my actual data set. I use "Fit Y by X" put height in Y, sex in X, then put a Normal Quantile Plot on it. Click and drag in the quantile plot to select the data points that are in the highest quantile regardless of X. (This is trivial with only two genders, but the actual data I was working with had about 7 discrete X values with wildly different Y values.) Then I go back to the data table with just the tallest selected and in the Rows box, right click selected and choose "Data View". It pops up a data table with only the highest quantile values of each X with all columns preserved. Not the most elegant solution, but I got it!

8d252d0d-562e-47b0-aee2-5d0a6aa63843.jpg

ron_horne
Super User (Alumni)

Re: The tallest girl in Big Class is 66 inches, but who is she?

If you are looking for all the columns (to get all the information available) for the maximum value per group you can get it in a new table as such:

Names Default To Here( 1 );
dt = Open( "$sample_data\big class.jmp" );
dt << select where ( :height == Col Max( :height, :sex))
dt1 = dt << Subset( Selected Rows( 1 ), Selected columns only( 0 ) );
dt << clear select();