Subscribe Bookmark RSS Feed

How to save a matrix formula into data table?

ba

Community Trekker

Joined:

Oct 22, 2013

Hi,

Does any of you know how to use JSL to save a matrix formula into data table, such as ([1] || (X1 + 1))* [2, 3] ?

Directly typing it in the formula editor works. But using JSL, it doesn't allow me to save any expression into matrices/vectors.

For example, Concat(1,Expr(X1+1)); is invalid.

I’ve also tried to save the expression into a list first and then multiply it with a numerical vector/matrix. But JSL complains that the lists and matrices cannot be mixed together in the formula.

Have you encountered any JSL example that can save such formula expressed in vectors/matrices? Many thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

I've just learned from Ryan Lekivetz the following script which works great!

myexp1 = nameexpr( ([1] || X1 + 1) * [2,3]);

dtt=current data table();

Eval(Substitute(

Expr(dtt << New Column("formula1 ",<<Formula(__form1__))),

Expr(__form1__), Eval Expr(myexp1),

));

One surprising thing I've found is that the JMP profiler doesn’t recognize such matrix formulas. For example, typing (:X1 || :X2 ) * [2, 3] or 2*:X1+3*:X2 in the formula editor could yield exactly the same result in the data table, but the profiler doesn’t recognize the first version. This may be a bug for the profiler.

1 REPLY
Solution

I've just learned from Ryan Lekivetz the following script which works great!

myexp1 = nameexpr( ([1] || X1 + 1) * [2,3]);

dtt=current data table();

Eval(Substitute(

Expr(dtt << New Column("formula1 ",<<Formula(__form1__))),

Expr(__form1__), Eval Expr(myexp1),

));

One surprising thing I've found is that the JMP profiler doesn’t recognize such matrix formulas. For example, typing (:X1 || :X2 ) * [2, 3] or 2*:X1+3*:X2 in the formula editor could yield exactly the same result in the data table, but the profiler doesn’t recognize the first version. This may be a bug for the profiler.