cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
ileshem
Level III

Make a variable from and average of selected rows in a column to use later as a reference line.

Hello,

 

I want your help with finding an average of selected row in a column and use it as a reference line in a graph.

I have a data table:

 

A

12.5

B

13.4

B

17.5

B

12.8

A

11.1

A

19.4

B

13.8

 

 I want to make a variable that is an average of all the “B” line values ((13.4+17.5+12.8+13.8)/4) in the example above.

Then I am going to use it as a reference line in a Bivariate graph.

 

1 ACCEPTED SOLUTION

Accepted Solutions
dale_lehman
Level VII

Re: Make a variable from and average of selected rows in a column to use later as a reference line.

If I am understanding what you want correctly, try creating a new variable using the Col Mean function with your first column as a "By" variable.  Then create another column with an IF statement that uses the B mean value for both groups A and B.  That column will then all have the same value = mean of the group B values.

View solution in original post

4 REPLIES 4
uday_guntupalli
Level VIII

Re: Make a variable from and average of selected rows in a column to use later as a reference line.

@ileshem , 
  Once the data table is openend , select random rows . You can do this by : 
Rows > Row Selection > Select Randomly

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

AgeVals = :age << Get Values ; // Get Values in Age Column 

SR = dt << Get Selected Rows(); // Get Selected Rows 

RequiredVar = AgeVals[SR,0]; // Desired Values subset from Column Values 

 

Best
Uday
ileshem
Level III

Re: Make a variable from and average of selected rows in a column to use later as a reference line.

Thanks for the prompt replay,
I was able to create a new table with the rows I wanted, but I am not sure how to calculate the MEAN of that column (VALUE) into a variable.
my_list = {"B"};
dtsub1 = dtEPData << subset(
rows( dtEPData << get rows where( Contains( my_list, :TYPE ) ) ),
Selected columns only( 0 ));



TYPE VALUE
A 12.5
B 13.4
B 17.5
B 12.8
A 11.1
A 19.4
B 13.8

Dtsub1=
TYPE VALUE
B 13.4
B 17.5
B 12.8
B 13.8





uday_guntupalli
Level VIII

Re: Make a variable from and average of selected rows in a column to use later as a reference line.

@ileshem , 
Col Mean() - if you want to use the column 

 

Mean() - if you want to use the matrix or a separate variable 

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt << Select Randomly( 0.3 );

dt1 = dt << Subset(Selected Rows( 1 ), selected columns( 0 )); 

Res = Col Mean(dt1:age); 

Show(Res);
Best
Uday
dale_lehman
Level VII

Re: Make a variable from and average of selected rows in a column to use later as a reference line.

If I am understanding what you want correctly, try creating a new variable using the Col Mean function with your first column as a "By" variable.  Then create another column with an IF statement that uses the B mean value for both groups A and B.  That column will then all have the same value = mean of the group B values.