Choose Language Hide Translation Bar
Highlighted
ezorlo
Level III

add a summary statistic column

Dear 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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ian_jmp
Staff

Re: add a summary statistic column

Is 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:

 

Screenshot 2020-03-24 at 10.03.20.png

View solution in original post

6 REPLIES 6
Highlighted
ian_jmp
Staff

Re: add a summary statistic column

Is 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:

 

Screenshot 2020-03-24 at 10.03.20.png

View solution in original post

Highlighted
ezorlo
Level III

Re: add a summary statistic column

Thanks for the prompt response!
It looks right, but my wife kicked me off the computer to watch the kids
so I'll try it soon and let u know.
Highlighted
ezorlo
Level III

Re: add a summary statistic column

I 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

Highlighted
txnelson
Super User

Re: 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 ) ) );
Jim
Highlighted
ezorlo
Level III

Re: add a summary statistic column

Thank 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 health
Highlighted
txnelson
Super User

Re: add a summary statistic column

My error.....I totally skipped over that you wanted the sum, not the mean....sorry
Jim
Article Labels

    There are no labels assigned to this post.