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
spartans5143
Level I

Select a Group of Columns based on the Group Name in JSL

Hello all,

I am writing a script that fits a neural net to the currently selected column of a data table.  I am currently hard coding the input columns in the JSL script, but to make it more easily transferable, I would like to have it use a group of columns that the user would name in the data table as the inputs.

To do this, I need to be able to select a group of columns based on the name given to the group, but I cannot figure out how to do it in JSL.  For example, in my case, I would like to group my input columns into a group named "Inputs" on the data table and then have the script find the columns named "Inputs" and select them.  The scripting guide discusses selecting columns based on position or their name, but it doesn't seem to mention how to select a group by the name you gave it on the data table.

Thanks for your help

Dennis

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Select a Group of Columns based on the Group Name in JSL

I don't know of a direct way to access the group name by JSL. One possible idea for a workaround is to dig out the name from the JSL-version of the table (i.e. dt<<get script).

Here's an example that seems to work:

//Open example table and make two groups of columns and name one "Inputs"

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

dt << Group Columns( "Inputs", height, 2 );

dt << Group Columns( :name, 2 );

//Select columns in group "Inputs"

t = dt << get script;

col_names = dt << get column names( string );

c = 0;

While( c >= 0,

  If( Arg( Arg( t, N Arg( t ) - c ), 1 ) == "Inputs",

       first_col = Char( Arg( Arg( t, N Arg( t ) - c ), 2 ) );

       group_size = Arg( Arg( t, N Arg( t ) - c ), 3 );

       first_col_nr = Contains( col_names, first_col );

       For( i = first_col_nr, i <= first_col_nr + group_size - 1, i++,

            Column( i ) << set selected( 1 )

            );

       c = -1;

       ,

       c++

       )

);

// make a list of the columns to use in further analyses...

Inputs_list = dt << get selected columns;

View solution in original post

3 REPLIES 3
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Select a Group of Columns based on the Group Name in JSL

I don't know of a direct way to access the group name by JSL. One possible idea for a workaround is to dig out the name from the JSL-version of the table (i.e. dt<<get script).

Here's an example that seems to work:

//Open example table and make two groups of columns and name one "Inputs"

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

dt << Group Columns( "Inputs", height, 2 );

dt << Group Columns( :name, 2 );

//Select columns in group "Inputs"

t = dt << get script;

col_names = dt << get column names( string );

c = 0;

While( c >= 0,

  If( Arg( Arg( t, N Arg( t ) - c ), 1 ) == "Inputs",

       first_col = Char( Arg( Arg( t, N Arg( t ) - c ), 2 ) );

       group_size = Arg( Arg( t, N Arg( t ) - c ), 3 );

       first_col_nr = Contains( col_names, first_col );

       For( i = first_col_nr, i <= first_col_nr + group_size - 1, i++,

            Column( i ) << set selected( 1 )

            );

       c = -1;

       ,

       c++

       )

);

// make a list of the columns to use in further analyses...

Inputs_list = dt << get selected columns;

spartans5143
Level I

Re: Select a Group of Columns based on the Group Name in JSL

That works great.  Thanks for your help.

cnattrass
Level II

Re: Select a Group of Columns based on the Group Name in JSL

Was looking for a solution for this and stumbled across the command Get Column Group. 

 

This Command also works