How to use JSL to extract formula text from a column and save it to a cell?For example, add a "test" column with "Big Class.jmp" and write a random formula.How do use JSL to save the formula extract formula text in this column to a cell in another column?
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column( "test" );
Column( "test" ) << Formula( If( age > 15, height + 50 + weight, height + 100 + weight ) );
dt << run formulas;
New Column( "txt", Character, "Nominal" );

ScriptingRe: How to use JSL to extract formula text from a column and save it to a cell?And I want to use JSL to achieve the formula to remove the newline character, but also to remove redundant space.Makes the formula text content stored in the cell simpler.
dt[1,"txt"]=
If(:age>15,:height+50+:weight,:height+100+:weight)
Thanks Experts!
Re: How to use JSL to extract formula text from a column and save it to a cell?You can get the formula with << Get Formula then change that to character and do required modifications
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("test", Formula(If(:age > 15, :height + 50 + :weight, :height + 100 + :weight)));
dt << New Column("txt", Character, "Nominal", << Set Each Value(
Substitute(Char(AsColumn(:test) << get formula), " ", "")
));Re: How to use JSL to extract formula text from a column and save it to a cell?See << get formula to retrieve the formula.
See Word() to retrieve the blank delimited elements to build a "blank removed" version of the formula or it can be done with a Regular Expression
Re: How to use JSL to extract formula text from a column and save it to a cell?done with a Regular Expression

Re: How to use JSL to extract formula text from a column and save it to a cell?The prediction formula derived from xGBoost training is too complex.
How to apply this prediction formula to new data is really complicated.
Re: How to use JSL to extract formula text from a column and save it to a cell?It depends on what the ultimate intention is here, but it might be more straightforward to persist the formula in cell of an expression column.
Re: How to use JSL to extract formula text from a column and save it to a cell?Yes, my use is to train the pattern once, get the prediction formula, and directly save the formula in text form in the cell.
When used for new data analysis, use the following form directly to calculate the new data using the original prediction formula
aaa = dt[1, "txt"];
Current Data Table( d2 );
Eval( Parse( "Column(d2,\!"test\!")<<FORMULA></FORMULA>
Thanks!