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
- :
- Re: Move Selected Columns() with list parameter

- 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

Jan 27, 2019 11:09 AM
(5789 views)

If I have a table with five columns:

Column 5 | Column 3 | Column 2 | Column 1 | Column 4 |

data | data | data | data | data |

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 1 | Column 2 | Column 3 | Column 4 | Column 5 |

data | data | data | data | 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

Highlighted

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

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));
```

Highlighted

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

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)) );
```

4 REPLIES 4

Highlighted

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

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));
```

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

Re: Move Selected Columns() with list parameter

Thanks, that works for me!

Highlighted

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

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)) );
```

Highlighted
##

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!

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

Re: Move Selected Columns() with list parameter

Article Labels

There are no labels assigned to this post.