cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
Fruit325
Level III

How to calcualte the average values from selected cells/rows/columns?

Hi, I'm wondering what would be the quickest way to calculate the average values from seleted rows/columns/cells on JMP 17? The average value from column 1 to column 6

Thank you! 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to calcualte the average values from selected cells/rows/columns?

One option is to use matrix calculations (as a reminder JMP is Not a Spreadsheet ) and Data table subscripting 

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 2])),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([3, 4, 3])),
	New Column("Column 3", Numeric, "Continuous", Format("Best", 12), Set Values([7, 8, 9]))
);

myvals = dt[1::2, 1::2];
myavg = Mean(myvals);
mymax  = Max(myvals);

https://www.jmp.com/support/help/en/17.2/#page/jmp/additional-ways-to-access-data-values.shtml#

-Jarmo

View solution in original post

6 REPLIES 6
jthi
Super User

Re: How to calcualte the average values from selected cells/rows/columns?

For what do you want the average for? Rows, Columns or Cells? All of these require different methods. For columns Summary, Tabulate or Col Mean formula are good options

-Jarmo
txnelson
Super User

Re: How to calcualte the average values from selected cells/rows/columns?

To add to Jarmo's answer, you can apply a Data Filter on your data to select the rows you want and then use the Summary

     Tables=>Summary

or the Tabulate Platform

     Analyze=>Tabulate

to get the statistics for the selected rows.

 

If you want to create a new column and only show in the new column the mean of selected rows, the below formula will work

Col Mean( If( Selected(), :your column, . ) )

 

 

Jim
Fruit325
Level III

Re: How to calcualte the average values from selected cells/rows/columns?

Thanks a lot! 

For example, I have a 3x3 table. I want to calculate final average value and maximum value for the top-left 4 cells from (0,0) to (2,2).

Is there any easy way to do that? Thank you! 

jthi
Super User

Re: How to calcualte the average values from selected cells/rows/columns?

One option is to use matrix calculations (as a reminder JMP is Not a Spreadsheet ) and Data table subscripting 

Names Default To Here(1);

dt = New Table("Untitled 2",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 2])),
	New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([3, 4, 3])),
	New Column("Column 3", Numeric, "Continuous", Format("Best", 12), Set Values([7, 8, 9]))
);

myvals = dt[1::2, 1::2];
myavg = Mean(myvals);
mymax  = Max(myvals);

https://www.jmp.com/support/help/en/17.2/#page/jmp/additional-ways-to-access-data-values.shtml#

-Jarmo
BHarris
Level VI

Re: How to calcualte the average values from selected cells/rows/columns?

Great answers from jthi and txnelson -- here's another:

 

Select the cells you're interested in, then copy/paste them into a new data table.  Further edit if needed, then Table->Stack the columns into a single column, then run a distribution analysis on that column and it will give you all the common statistics on that column.

ron_horne
Super User (Alumni)

Re: How to calcualte the average values from selected cells/rows/columns?

@BHarris ,
i would say this is perhaps the most JMPish way to do this.
snitching the script from the log windows is also useful for further generalisation if this needs to be done repeatedly with different selections.