- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Getting formula from column in a pretty format
I would like to obtain the formula of each column in a more readable format (also called pretty format).
For the example below I will like to obtain "height / weight
".
Simply removing ":" will not work as columns can have such character.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = New Column( "Ratio" );
col << Set Formula( :height / :weight );
col << Eval Formula;
result = col << Get Formula;
Show( result );
// result = :height / :weight;
// desired_result = "height / weight";
5 REPLIES 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Getting formula from column in a pretty format
Here is an example on how to do that
names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");
dt<< new column("Example", formula(sqrt(:Height/:Age+:Weight*:Height)));
new window("pretty", expr as picture(dt:Example << get formula));
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Getting formula from column in a pretty format
How would I obtain a string that reads the following in your example?
"sqrt(Height/Age + Weight*Height))"
Is there any 'expr as formula'?
"sqrt(Height/Age + Weight*Height))"
Is there any 'expr as formula'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Getting formula from column in a pretty format
Try this
names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");
dt<< new column("Example", formula(sqrt(:Height/:Age+:Weight*:Height)));
charFormula = char(dt:Example << get formula);
substitute into(charFormula,
expr(":"), expr(" ")
);show(charFormula);
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Getting formula from column in a pretty format
The main limitation is that I might have ":" in the name that is not due to the formula.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Getting formula from column in a pretty format
JSL syntax requires colons to refer to columns, but there are other options such as what I show here.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Ratio", Set Formula( ascolumn("height") / ascolumn("weight")));
Not sure if it's more pretty though