add a summary statistic columnDear Community
first best wishes for good health!
i need to add summary statistic for a data table with a grouping variable. i want the summary statistic to appear in every row that the matching grouping variable appears.
what i've done until now is to create a separate summary statistic table and then manually recode the grouping variable column. this is a bit tedious. is there a way to just merge the recode and summary table?
see pics
Thank you
Re: add a summary statistic columnMy error.....I totally skipped over that you wanted the sum, not the mean....sorryRe: add a summary statistic columnThank you both very much I was able to make the column!!
This saved me from manually recoding the grouping variable column. Also this script was useful for helping me to understand the col sum function better, which I used in a formula to achieve the same result. Thanks again and best of healthRe: add a summary statistic column@ian_jmp gave you an example of what you need to use, he just didn't put it into the specifics of your data table. So if you run this little script, against your data table, it should give you what you want.
Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Mean OTU Grouped by Plot and replicate",
formula( Col Mean( :OTU, :Plot and replicate ) ) );Re: add a summary statistic columnI am not accomplishing the task
Here is the output of the summary table script:
Tabulate(
Add Table( Column Table( Analysis Columns( :OTU ) ), Row Table( Grouping Columns( :Plot and replicate ) ) )
)
It gives me the exact statistic that i need in one row per grouping variable. now i need it to repeat for each row with the grouping variable (and i have 73000 rows!)
anyway i am new to scripting so pardon my obvious lack of experience
Re: add a summary statistic columnThanks for the prompt response!
It looks right, but my wife kicked me off the computer to watch the kids 8)
so I'll try it soon and let u know.
Re: add a summary statistic columnIs this what you are after? Do 'File > New Script', copy and paste the code below, then 'Edit > Run Script'.
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column( "Mean weight Grouped by age", Formula( Col Mean( :weight, :age ) ) );
If so, take a look at the formula column in the table. Using 'Help > Scripting Index' gives some other possibilities:
