Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Reference for new column generated by FitMode-SaveColumn

- 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

Sep 25, 2018 9:11 AM
(4880 views)

Hi,

I am trying to get the name of the residual column generated by fit model in JSL. That way, I can scale up the residual by 1000 in the following line. Here is my script.

```
Model = Fit Model(
Y( :Raw Leveling ),
Effects(
:Xa,
:Ya,
Transform Column( "Xa^2", Formula( :Xa * :Xa ) ),
Transform Column( "Ya^2", Formula( :Ya * :Ya ) ),
Transform Column( "Xa*Ya", Formula( :Xa * :Ya ) )
),
Personality( "Standard Least Squares" ),
Emphasis( "Minimal Report" ),
Run
);
Model << Residuals;
New Column("Residual (nm)", formula(Column(10)[]*1000));
```

Now I have to use column # to do the scale up. If I can get the column name of the residual column(generated with Model << Residuals), the script could be applied to a different table, and I don't have to change the column # manually.

This is also related to a more general question. How can I get a reference to the column automatically generated by JMP?

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

Created:
Sep 25, 2018 9:52 AM
| Last Modified: Sep 25, 2018 9:57 AM
(4878 views)
| Posted in reply to message from Zihao 09-25-2018

Hi @Zihao,

I don't know of a way to pull a column reference from the residual message itself, but since the saved column will always be the last in the table what I've done in this kind of situation is make a variable reference to the final column based on the number of columns in the table. Something like the following:

```
dt = current data table();
lastColumn = column(nCols(dt));
```

Perhaps that will work in your situation so you won't need to hardcode a column number? So, in your case, a simple way to make the new column based on the above would be:

`New Column("Residual (nm)", SetEachValue(lastColumn[]*1000));`

I hope this helps,

3 REPLIES 3

Highlighted

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

Created:
Sep 25, 2018 9:52 AM
| Last Modified: Sep 25, 2018 9:57 AM
(4879 views)
| Posted in reply to message from Zihao 09-25-2018

Hi @Zihao,

I don't know of a way to pull a column reference from the residual message itself, but since the saved column will always be the last in the table what I've done in this kind of situation is make a variable reference to the final column based on the number of columns in the table. Something like the following:

```
dt = current data table();
lastColumn = column(nCols(dt));
```

Perhaps that will work in your situation so you won't need to hardcode a column number? So, in your case, a simple way to make the new column based on the above would be:

`New Column("Residual (nm)", SetEachValue(lastColumn[]*1000));`

I hope this helps,

Highlighted
##

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

Re: Reference for new column generated by FitMode-SaveColumn

Hi Julian

Thanks for sharing your idea.

Yes, one alternative way would be just using the total number of columns to point to the last column.

Another idea I have is Can I assign a column name when it is generated by the Fit Model function? That would also be easy to customize the script.

Thanks!

-Zihao

Highlighted
##

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

Re: Reference for new column generated by FitMode-SaveColumn

Functions might make this sort of thing feel more straightforward if doing this more than once in a script. Expanding on @julian's answer:

```
//Saves residuals column and returns reference to column
SaveResiduals = function({mdl},
mdl << Residuals;
dt = mdl << get data table;
column( nCols( dt ) );
);
rescol = SaveResiduals(Model);
rescol << Set Name("Residuals");
```

Article Labels

There are no labels assigned to this post.