I have a dataset of daily ozone concentrations from multiple sites over several years. Is there a quick way to subset the top ten highest concentrations at each site and year?
Here is an example of a simple way to create a table with just the top 10 for each group(site)
names default to here(1); dt=// Open Data Table: Big Class.jmp // → Data Table( "Big Class" ) Open( "$SAMPLE_DATA/Big Class.jmp" ); dt << sort(by(:sex, :height), order(descending,descending), replace table(1)); dt<< select where(col cumulative sum(1, :sex) <=10); dtFinal = dt << subset(output table("Top 10"), selected rows(1), selected columns(0));
You can create formula to get top10, use summary or tabulate. And then depending on how your data looks like you might need additional calculation to easily get the top10
Hi, I am very happy to learn about "select where(col cumulative sum(1, :sex) <=10)".
I am wondering if I can push it further, say if I want to select top 5 for male, and top 7 for female? Many thanks in advance.
dt << select where( Col Cumulative Sum( 1, :sex ) <= Match( :sex, "M", 5, 7 ) );