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
- :
- JSL - Combining Columns from a table for a functio...

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

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

Nov 23, 2016 8:14 AM
(962 views)

I am trying to apply a function to multiple columns at the same time, and I am struggling to figure out how to do this.

Suppose that a Table has "Column 1" and "Column 2" and I want to calculate a quartile of the combined data, essentially I want to stack column 1 on top of column 2, say something like this:

q1 = Col Quartile({:Column 1, :Column 2},0.25);

This does not work.. but it seems like there is a simple solution... Any advice or solutions?

Thank you in advance!

Brad

1 ACCEPTED SOLUTION

Accepted Solutions

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

Nov 23, 2016 8:26 AM
(1914 views)

Solution

It sounds like you are using column formulas. This solution should work in a column formula or in a script. I assume that your data table is already open. I opened Big Class to demonstrate the solution. You have to double click the formula so that you can directly type or paste text and then press Enter key.

// assume your data table is already open // example here is Open( "$SAMPLE_DATA/Big class.jmp" ); Quantile( 0.25, (:height << Get As Matrix) |/ (:weight << Get As Matrix) );

So the Quantile function takes the desired percentile (0.25 for first quartile) as its first argument and a collection of data (list, matrix) as its second argument. It works with any collection of data. (The Col Quantile function is a specialized function that works with a data columnn and retains the result to avoid redundant future computation.) The second argument here is formed by vertically concatenating (symbol is |/ for this operator) the two column vectors obtained from the data columns. The vertical concatenation of the matrices is equivalent to your idea of stacking data columns in the data table. You can extend this concatentaton to any number of columns.

Learn it once, use it forever!

2 REPLIES

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

Nov 23, 2016 8:26 AM
(1915 views)

It sounds like you are using column formulas. This solution should work in a column formula or in a script. I assume that your data table is already open. I opened Big Class to demonstrate the solution. You have to double click the formula so that you can directly type or paste text and then press Enter key.

// assume your data table is already open // example here is Open( "$SAMPLE_DATA/Big class.jmp" ); Quantile( 0.25, (:height << Get As Matrix) |/ (:weight << Get As Matrix) );

So the Quantile function takes the desired percentile (0.25 for first quartile) as its first argument and a collection of data (list, matrix) as its second argument. It works with any collection of data. (The Col Quantile function is a specialized function that works with a data columnn and retains the result to avoid redundant future computation.) The second argument here is formed by vertically concatenating (symbol is |/ for this operator) the two column vectors obtained from the data columns. The vertical concatenation of the matrices is equivalent to your idea of stacking data columns in the data table. You can extend this concatentaton to any number of columns.

Learn it once, use it forever!

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

Nov 23, 2016 9:19 AM
(953 views)

Brad