cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
JMPUser9
Level II

Equations to open in new data table

I need to calculate two separate equations to open in two columns in a new data table. Is there a way to do so?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Equations to open in new data table

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 ) );

txnelson_0-1687816089277.png

 

Jim

View solution in original post

4 REPLIES 4

Re: Equations to open in new data table

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?

txnelson
Super User

Re: Equations to open in new data table

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 ) );

txnelson_0-1687816089277.png

 

Jim
JMPUser9
Level II

Re: Equations to open in new data table

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. 

txnelson
Super User

Re: Equations to open in new data table

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" ) );
);
Jim