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

Using loop variable as column input

Hello,

 

I am wondering if it possible to use my for loop variable, i, as an input for a new column, depending on the value of another column.  Here is what I am thinking, but cannot get to work.

dt << New Column("Site", Numeric, Formula(
   For(i = 1, i <= 8, i++,
      If(Contains(:Column1, i), i);
   )
));

 

2 REPLIES 2
txnelson
Super User

Re: Using loop variable as column input

You certainly can.  The only issue you have is that the Contains() function is a character handling function, and the arguments passed to it must be character(string) values.  I am assuming :Column1 is a character column so all you need to do is to convert the index variable "i" from a numeric to character

dt << New Column("Site", Numeric, Formula(
   For(i = 1, i <= 8, i++,
      If(Contains(:Column1, char(i) ), i);
   )
));
Jim
pauldeen
Level VI

Re: Using loop variable as column input

What is it your a trying to do, do you have some example data?

Do you want to copy the value of Column1 to another column?

Do you want to take the value from another column based on the numeric reference in column1?