cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
emmablue
Level III

how to use jsl to calculate standard deviation by ID

Hi, I have a table similar to this, and I wanted to select IDs where there are more than one entry and calculate standard deviation of the result grouped by ID. For example, in this case, I need to select ID 12345 and calculate standard deviation of the first 3 results. 

 

I know I can do this by tabulate, but my actual table is very big, more than 1 million rows, tabulate by ID and calculate standard deviation turns out to be extremely time consuming. Most IDs in my actual table have only one row. Is there anyway I can do something like this and then calculate standard deviation for the remaining results group by ID? Thank you for your suggestion!

 

                        select where(n rows(grouping columns (:ID))>1)

 

IDresult
123450.3
123450.4
123450.2
234560.5
345670.2
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: how to use jsl to calculate standard deviation by ID

Select your grouping column (ID)

jthi_0-1718823059761.png

Then select the column you wish to perform the calculation on and pick Standard Deviation (note the Grouping by id)

jthi_1-1718823097679.png

jthi_2-1718823115628.png

jthi_3-1718823145121.png

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: how to use jsl to calculate standard deviation by ID

Select your grouping column (ID)

jthi_0-1718823059761.png

Then select the column you wish to perform the calculation on and pick Standard Deviation (note the Grouping by id)

jthi_1-1718823097679.png

jthi_2-1718823115628.png

jthi_3-1718823145121.png

-Jarmo
jthi
Super User

Re: how to use jsl to calculate standard deviation by ID

Few more options

 

Create summary table

jthi_5-1718861375094.png

 

After you have the summary table, you can click on the stddev column and hold mouse down for some time. This allows you to "pick" the column and drop it to your original table

jthi_6-1718861375055.png

 

 

You could also have used Update with the summary table

jthi_7-1718861374827.png

 

 

You can create similar table using Tabulate (note that id is nominal)

jthi_8-1718861374816.png

 

Then from red triangle, make into data table

jthi_9-1718861374826.png

 

you can then use Update (or join) to get the results back to your table.

 

There are also many scripting options, here is one using Summarize() 

 

Names Default To Here(1);

dt = Current Data Table();

Summarize(ids = by(:ID), stddevs = Std dev(:result));
show(ids, stddevs); 
// ids = {"12345", "23456", "34567"}; // note that these are strings even if they were numbers originally
// stddevs = [0.1, ., .];

 

-Jarmo