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
- :
- How to Fit Y by X where Variables Cycle Through Certain Columns?

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

How to Fit Y by X where Variables Cycle Through Certain Columns?

Jun 23, 2016 4:37 PM
(1314 views)

**Hello everyone,**

**I am trying to figure out how to Fit Y by X, where Y cycles through all of my Numerical-Continuous columns ending in "_CODED" that have been produced earlier in the script. After every column has been used as Y for the first X, I'd like to have the next "_CODED" column be used as a new X, and have the Y columns be cycled through again, until all possible graphs have been produced, preferably in a single window instead of separate windows.**

**I am having trouble using a variable for the CODED columns in the Bivariate portion of the script, which is what I think I need to do, but everything I've tried so far has produced errors. Could someone look through what I have and try to help me with this? **

dt = Data Table("data.jmp");

cols = dt << get column names(Character); //List all character columns

For (i = 1, i <= N Items(cols), i++,

one_col = cols* << get name;*

coded_col = one_col || "_CODED";

col_expr = evalinsert(

"\[ dt << New Column("^coded_col^", Numeric, "Continuous",

Format("Best", 12), Formula(

if (:name("^one_col^") == "PASS", 1,

:name("^one_col^") == "FAIL", 2,

:name("^one_col^") == "", 3,

:name("^one_col^") == "NOTTESTED", 4,

:name("^one_col^") == "IGNORE", 5,

:name("^one_col^") == "PASS|PASS", 6,

:name("^one_col^") == "IGNORE|IGNORE", 7,

:name("^one_col^") == "NOTTESTED|NOTTESTED", 8;

);

)

);]\");

eval(parse(col_expr))

);

**//That was all to produce new Numerical-Continuous columns out of the columns I have. Continuing the script, I am trying to create Y by X graphs of these new columns. I'm actually not quite sure what to do here..**

Bivariate(

Y( (coded_col),

X( (coded_col*),*

Fit Line( {Line Color( {213, 72, 87} )} )

)

)

;

)

1 REPLY 1

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

Re: How to Fit Y by X where Variables Cycle Through Certain Columns?

Not sure I understood your intention exactly, but FYI, you can do this kind of thing:

NamesDefaultToHere**(****1****)**;

// Sample Data

dt = NewTable**(**"Data",

NewColumn**(**"Not X", Numeric, Continuous, Formula**(**RandomInteger**(****0**, **3****)))**,

NewColumn**(**"Not Y", Numeric, Continuous, Formula**(**RandomInteger**(****0**, **3****)))**,

AddRows**(****20****)**;

**)**;

For**(**c=**1**, c<=**5**, c++,

dt << **NewColumn****(**"VAR"||Char**(**c**)**||"_CODED", Numeric, Continuous, Formula**(**RandomNormal**()))**;

**)**;

// Get all the columns in the table dt . . .

cols = dt << **getColumnNames****(**"String"**)**;

// Retain only the columns we want

For**(**c=NItems**(**cols**)**, c>=**1**, c--,

If**(**!EndsWith**(**cols**[**c**]**, "_CODED"**)**, RemoveFrom**(**cols, c**))**;

**)**;

// Launch the platform (makes 5 x 5 = 25 plots)

biv = dt << **FitYByX****(**X**(**Eval**(**cols**))**, Y**(**Eval**(**cols**)))**;