Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Make a variable from and average of selected rows in a column to use later as a ...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Dec 11, 2017 10:20 AM
(2345 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Uday

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Uday

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content