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
handerson89
Level I

Creating formulas in a new column. JMP script

Hello all. I am needing to create a new column that will subtract the contents of consecutive rows and insert that value into the new column. 

 

Essentially I want to say: In column X, subtract row 1 from row 2 and place that value in column Y. I want this to continue for the entirety of Column X.

 

Therefore: Column Y = X(i+1) - Xi; i being the row number. Anyone know how to do this? Seems simple enough but I am very new to scripting and having a hard time getting something to stick.

3 REPLIES 3
txnelson
Super User

Re: Creating formulas in a new column. JMP script

  1. You need to read the Discovering JMP document, and the Scripting Guide!
  2. You need to attempt to solve the problem first.  One learns by making mistakes and figuring out what the problem is
  3. When you fail at solving the problem, the Discussion Community is there to help.
  4. Below is a script that if you have setup your data table correctly, should show you one way to solve the problem
    Names Default to Here( 1 );
    
    // Open Data Table: big class.jmp
    // → Data Table( "big class" )
    Open( "$SAMPLE_DATA/big class.jmp" );
    
    // New column: Column 6
    Data Table( "big class" ) << New Column( "New Column",
    	Numeric,
    	"Continuous",
    	Format( "Best", 12 ),
    	Formula( :weight[Row() + 1] - :weight )
    );
Jim

Re: Creating formulas in a new column. JMP script

Hi,

 

As Jim mentions, studying up will help, although admittedly the sheer volume of information can be a bit intimidating at first.

 

Since much of what can be accomplished through scripting can also be done interactively, be sure to check out 1-click formulas, which easily create some of the most commonly encountered formulas.

 

In your example, you can right-click on any value in the original column and select New Formula Column > Row > Difference from the ensuing menu. This creates a new column with the desired formula, in a single step.

 

Cheers,

Brady

 

 

brady_brady_0-1625687612364.png

 

markschahl
Level V

Re: Creating formulas in a new column. JMP script

One addition to what Brady^2 said: you can create formula columns in any platform using this method:
https://www.jmp.com/support/help/en/16.0/#page/jmp/transform-columns-in-a-jmp-platform.shtml 

I used to create a lot of formula columns in data tables. I now do less of that, and use the method above a lot.