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
- :
- Discussions
- :
- Re: How to select a column with specific name?

Topic Options

- Start Article
- 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
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 20, 2015 10:19 AM
(8362 views)

Hi

Assume I have a table with columns 1-10.

then I have a 3 variables. for example A=2, B=7, C=10

I want to write a script to select columns with amounts of A, B, and C and plot it vs col.1.

here it should select columns of 2, 7, and 10 and use overlay plot to plot it vs column1.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

Selecting columns by name is easy enough:

dt = Current Data Table**()**;

a = **2**;

b = **7**;

c = **9**;

Column**(** dt, Char**(** a **)** **)** << **Set Selected**;

Column**(** dt, Char**(** b **)** **)** << **Set Selected**;

Column**(** dt, Char**(** c **)** **)** << **Set Selected**;

But I'm not sure you need to select them to create the overlay plot you are looking for. You can just do this:

**Overlay Plot(** X**(** :Name**(** "1" **)** **)**, Y**(** Column**(** dt, Char**(**a**)** **)**, Column**(** dt, Char**(**b**)** **)**,

Column**(** dt, Char**(**c**)** **)** **)** **)**;

If you have a variable number of Y variables, you can construct a list of them and set that list as the Y variables for overlay plot:

colList = **{}**;

colList = Insert**(** colList, Column**(** dt, Char**(** a **)** **)** **)**;

colList = Insert**(** colList, Column**(** dt, Char**(** b **)** **)** **)**;

colList = Insert**(** colList, Column**(** dt, Char**(** c **)** **)** **)**;

**Overlay Plot(** X**(** :Name**(** "1" **)** **)**, Y**(** EvalList**(**colList**)** **)** **)**;

HTH,

Eric

3 REPLIES 3

Highlighted

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

Selecting columns by name is easy enough:

dt = Current Data Table**()**;

a = **2**;

b = **7**;

c = **9**;

Column**(** dt, Char**(** a **)** **)** << **Set Selected**;

Column**(** dt, Char**(** b **)** **)** << **Set Selected**;

Column**(** dt, Char**(** c **)** **)** << **Set Selected**;

But I'm not sure you need to select them to create the overlay plot you are looking for. You can just do this:

**Overlay Plot(** X**(** :Name**(** "1" **)** **)**, Y**(** Column**(** dt, Char**(**a**)** **)**, Column**(** dt, Char**(**b**)** **)**,

Column**(** dt, Char**(**c**)** **)** **)** **)**;

If you have a variable number of Y variables, you can construct a list of them and set that list as the Y variables for overlay plot:

colList = **{}**;

colList = Insert**(** colList, Column**(** dt, Char**(** a **)** **)** **)**;

colList = Insert**(** colList, Column**(** dt, Char**(** b **)** **)** **)**;

colList = Insert**(** colList, Column**(** dt, Char**(** c **)** **)** **)**;

**Overlay Plot(** X**(** :Name**(** "1" **)** **)**, Y**(** EvalList**(**colList**)** **)** **)**;

HTH,

Eric

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

Re: How to select a column with specific name?

If you want to use column 1 as x, and columns 2, 7, and 10 as Y, regardless of their names, then this will do the trick:

dt = current data table**()**;

xc = **1**; // column 1

a = **2**; // column 2

b = **7**; // column 7

c = **9**; // column 9

overlay plot**(**x**(**column**(**xc**))**, y**(**column**(**a**)**, column**(**b**)**, column**(**c**)))**;

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

Re: How to select a column with specific name?

Hi Eric,

I have another question looks like last one:

columns a, b, c are variables; how can I add new column and give it a formula by use of a,b, and c?

I wrote following script but column doesn't show the formula.

New Column**(** "a /b",Numeric,Continuous,Format**(** "Best", **12** **)**,

Formula**(** :column**(**char**(a****))** / :column**(** char**(b****))** **))**;

thank you for your recommendation