Subscribe Bookmark RSS Feed

Creating a subset of selected Rows in a datatable

juliet

Community Trekker

Joined:

Feb 19, 2013

Hi All,

I'm fairly new to JSL, and am hoping to get some assistance with an issue I've run into.

I'm trying to create a subset of selected rows (with all columns preserved) from a datatable, but in spite of trying just about everything I can find on these forums, in the JMP scripting guide, and in "Jump into JMP Scripting", I haven't been able to get this to happen.

The closest I've come is with the following, which creates the subset table, but includes all rows rather than just the ones I've selected (and the rows I want ARE selected in the main table) and also eliminates some columns.

data table("JoinedOutput") <<Select Where (Dilution==0.00005);

selRows = N row( dt << Get Selected Rows );

dt << Subset( output table name("JoinedSubset"));


What are people's thoughts? Any and all help is much appreciated!

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

It should work. But are you sure that dt really is the data table "JoinedOutput" and not another table (perhaps the original table before joining...)?

However, Subset() may produce more predictable results with some optional arguments. Try something like this:

dt = Data Table( "JoinedOutput" );

dt << Select Where( :Dilution == 0.00005 );

dt << Subset( Output Table( "JoinedSubset" ), Selected Rows( 1 ), selected columns( 0 ) );

5 REPLIES
Solution

It should work. But are you sure that dt really is the data table "JoinedOutput" and not another table (perhaps the original table before joining...)?

However, Subset() may produce more predictable results with some optional arguments. Try something like this:

dt = Data Table( "JoinedOutput" );

dt << Select Where( :Dilution == 0.00005 );

dt << Subset( Output Table( "JoinedSubset" ), Selected Rows( 1 ), selected columns( 0 ) );

juliet

Community Trekker

Joined:

Feb 19, 2013

It's interesting that you should ask that question, because at an earlier point in my script i have specified:

dt=data table("JAT-00047 Day 0-45 concat");


which is the initial table used in my analysis. The subset step is coming several steps later, on the 3rd table used in the analysis. My understanding was that by specifying:

data table ("JoinedOutput")

I could specify that I wanted a subset of this table, but now I'm guessing this is wrong?

Will I encounter a problem using the dt = Data Table ( "JoinedOutput" ) here if I've used it as shown above earlier in the script?

Thank you!

pmroz

Super User

Joined:

Jun 23, 2011

The safest thing is to have a separate variable for each table.  Avoids confusion that way.  Referring to a table via data table("Table title") works but is a little more verbose.

FrankBot0211

New Contributor

Joined:

May 9, 2017

Hi,

 

Can you explain what is the returning of Selected Rows(1), and Selected Columns(0). without that script does not work.

David_Burnham

Super User

Joined:

Jul 13, 2011

Subset performs the same task as the Subset option on Tables menu of JMP.  If you look at that option you will see that when you subset you have to indicate whether or not to use all rows and columns, or only selected rows and/or columns.

The arguments are providing the same information: Selected Rows(1) says that you want to use only the selected rows; Selected Columns(0) means you don't want to use selected columns (by implication, you want to use all columns).  

-Dave