I need to calculate two separate equations to open in two columns in a new data table. Is there a way to do so?
Is this what you are talking about. This script creates 2 new columns, each with a different formula:
Names Default To Here( 1 ); dt = // Open Data Table: Big Class.jmp // → Data Table( "Big Class" ) Open( "$SAMPLE_DATA/Big Class.jmp" ); dt << New Column( "one", formula( :height + :weight ) ); dt << New Column( "two", formula( :height / :weight ) );
Yes, but we'll need more specifics to give a useful answer. What steps do you need to take, and are you looking for a scripting answer, or one that can be accomplished in the GUI?
Jim, thanks for the feedback. I'm looking to run a script where
select where name is Katie and Tim, then height = 59 + 60
In a new table
Names Height Sum
Katie/Tim 119
And then any combinations I specifically call out.
Here is a simple script that provides one solution
Names Default To Here( 1 ); dt = // Open Data Table: Big Class.jmp // → Data Table( "Big Class" ) Open( "$SAMPLE_DATA/Big Class.jmp" ); theNames = {"KATIE", "TIM"}; theRows = dt << get rows where( dt:name == theNames[1] | dt:name == theNames[2] ); If( N Items( theRows ) == 2, dt2 = New Table( "Results" ); dt2 << add rows( 1 ); New Column( "Names", character, set each value( theNames[1] || "/" || theNames[2] ) ); New Column( "Height Sum", set each value( Sum( dt:height[theRows] ) ) ); Try( dt2 << delete columns( "Column 1" ) ); );