Hi JMP Community,
I have generated multiple prediction formulas stored in columns and I need to extract the parameters to evaluate which variables are common across formulas.
When I call for dt:Column X << Get formula, the output is not a string or list that can be used with standard pattern extraction functions (e.g., Words (), Munger ()...).
Questions:
- Am I using the right function to collect the formula parameters by using << Get Formula?
- If not, what would be a more appropriate function?
- If yes, is there a trick to convert the << Get formula output to a string, list, or matrix?
Thank you for your help.
Best,
TS
I'm going to document another approach to this here. (Thanks to @Byron_JMP for the Arg() tutorial on this)
You can go through an Arg() command to get the parameters as a list that you can work with pretty easily. I've also put a function below that returns the parameters for a column formula as an Associative Array.
// For a given column, col, in a data table, dt, you can get the formula column property with a message:
formula = dt:Col << Get Formula;
// the first argument of which is the parameters list which can be extracted using Arg()
params = Arg(formula, 1);
// from there you can index down to get the parameter / value pair
parameterName1 = Arg(params[1],1);
parameterValue1 = Arg(params[1],2);
And the Function that returns the formula parameters as an associative array
// This function expects a column reference
formulaParameters = Function( {colref},
{default local},
plist = Arg( colref << Get Formula, 1 );
keys = {};
values = {};
For Each( {value, index}, plist,
Insert Into( keys, Arg( value, 1 ) );
Insert Into( values, Arg( value, 2 ) );
);
parameters = Associative Array( keys, values );
);
// Usage example:
dt = Current Data Table();
columnWithParameters = dt:Col1 << Get Column Reference();
parameterAArray = formulaParameters( columnWithParameters );If the interest is in the variable names inside the formula, it might be easier to work directly with the formula expression. Here is an example which extracts unique symbol names out of a formula.
dt = open("$sample_data/Reliability/Locomotive.jmp");
ex = column(dt, 3)<<GETFORMULA></GETFORMULA>Being pretty "Old School", I handle it by retrieving the formula as a character string
Names Default To Here( 1 );
dt = Current Data Table();
x = Char( dt:predicted height << get formula );