Reference for new column generated by FitMode-SaveColumnHi,
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?
Re: Reference for new column generated by FitMode-SaveColumnFunctions 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");Re: Reference for new column generated by FitMode-SaveColumnHi 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
Re: Reference for new column generated by FitMode-SaveColumnHi @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,
@julian