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
john_madden
Level VI

Move Selected Columns() with list parameter

If I have a table with five columns:

 

Column 5Column 3Column 2Column 1Column 4
datadatadatadatadata

 

and I execute this:

dt = Current Data Table();
dt << Move Selected Columns({"Column 1", "Column 2", "Column 3", "Column 4", "Column 5"}, To first)

then I get this:

Column 1Column 2Column 3Column 4Column 5
datadatadatadata

data

 

But if I execute this:

dt= Current Data Table();
list = {"Column 1", "Column 2", "Column 3", "Column 4", "Column 5"};
dt << Move Selected Columns( list, To first); 

it fails with an "Unrecognized key word" error.

 

I need to be able to parameterize the column list, as in the second version. How can I make something like the second version work? 

2 ACCEPTED SOLUTIONS

Accepted Solutions
pmroz
Super User

Re: Move Selected Columns() with list parameter

I tried various flavors of as list(), listeval(), expr, evalexpr(), etc. to no avail.  Had to resort to eval(parse()):

dt = current data table();

alist = {"Column 4", "Column 3", "Column 2", "Column 1"};
clist = char(alist);

col_expr = evalinsert("dt << move selected columns(^clist^, to first)");

eval(parse(col_expr));

View solution in original post

gzmorgan0
Super User (Alumni)

Re: Move Selected Columns() with list parameter

This is just an alternate method, and FYI.

 

You can also do this with expressions.  Eval Expr() replaces each Expr() with its value (name expression), and the external Eval() function, executes the command.

 

dt= Current Data Table();
list = {"Column 1", "Column 2", "Column 3", "Column 4", "Column 5"};
Eval( Eval Expr(dt << Move Selected Columns( Expr(list), To first)) ); 

View solution in original post

4 REPLIES 4
pmroz
Super User

Re: Move Selected Columns() with list parameter

I tried various flavors of as list(), listeval(), expr, evalexpr(), etc. to no avail.  Had to resort to eval(parse()):

dt = current data table();

alist = {"Column 4", "Column 3", "Column 2", "Column 1"};
clist = char(alist);

col_expr = evalinsert("dt << move selected columns(^clist^, to first)");

eval(parse(col_expr));
john_madden
Level VI

Re: Move Selected Columns() with list parameter

Thanks, that works for me!
gzmorgan0
Super User (Alumni)

Re: Move Selected Columns() with list parameter

This is just an alternate method, and FYI.

 

You can also do this with expressions.  Eval Expr() replaces each Expr() with its value (name expression), and the external Eval() function, executes the command.

 

dt= Current Data Table();
list = {"Column 1", "Column 2", "Column 3", "Column 4", "Column 5"};
Eval( Eval Expr(dt << Move Selected Columns( Expr(list), To first)) ); 

Re: Move Selected Columns() with list parameter

I'm glad to hear a workaround has been found. In the meantime, we reported this issue to development, and JMP 15 (available later this year) has been updated so that the evaluation will happen automatically. Thanks!