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
Create multiple lag columns

Here is a script that can be used to create multiple lag columns of varibles in a data table.  This may be useful if your data is skewed in time.  For example, if sensor data is being captured in time, and the data in your table is ordered chronologically, then data corresponding to one batch or product may be spread out over multiple rows.  The script will allow you to easily align the data for analysis.

Names Default To Here(1);

dt=current data table();
/* Query the user for a column roles. */
cdlg = Column Dialog( 

ycol = ColList( "Y", MinCol( 1 ), MaxCol( ), Data Type("Numeric"),Modeling Type("Continuous") ),

Line Up( 2,
		"Start Lag", slag = Edit Number( 32 )),
Line Up( 2,
		"End Lag", elag = Edit Number( 38 ))
);



If( cdlg["Button"] == -1, Throw( "User cancelled" ) );
Remove From( cdlg ); Eval List( cdlg );

range=elag-slag;

If( range <= 0, Throw( "Bad Range" ) );

/* Unload the values from the Column Dialog */
my_collist = cdlg["ycol"];

/*Number of columns chosen*/
numcols=N Items(my_collist);


for(i=1,i<=numcols,i++,

for(j=slag,j<=elag,j++,


newcol=dt << New Column( Char(my_collist[i]) ||" Lag "||Char(j));
newVals = (J(j,1,.) |/ (Column(dt,my_collist[i]) << Get Values))[1::N Row(dt)];
newcol<<Set Values(newVals);
	
));

Recommended Articles