cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
natalie_
Level V

Removing values from a column

Hi All,

 

I would like to remove values from a column.  Normally, I would use a range check column property to do this, but with this particular column, it is also dependendent on another column's value.  Is there an easy way to do this?

 

I tried the code below, but unfortunately it makes the entire column blank except for the first row.  I thought this might work because the "." represents missing values.  The data and modeling types are numeric and continuous.

 

For(i=1, i<=NRows(dt), i++,

If(dt:Col 1[i] < someValue, If(dt:Col 2[i]==1,  ,dt:Col 1[i] = "."),dt:Col 1[i] = ".");


);

3 REPLIES 3
natalie_
Level V

Re: Removing values from a column

I found a way to make it work, but I don't know how efficient it is.  I saved the values from the columns to lists, deleted the one column, made a new column, and added the passed values to the new column.  If it wasn't a passed observation, it wasn't add and the entry in that cell is simply a "."

 

idList = List();
idList = As List(:Col X<< get values);
idLogic = List();
idLogic = As List(:Col Y<<get values);


dt << New Column("Col X", Numeric, Continuous);


For(i=1, i<=N Rows(dt), i++,

If(idList[i] < someValue, If(idLogic[i]==1,dt:Col X[i] = idList[i],),);

);

txnelson
Super User

Re: Removing values from a column

Natalie,

I believe that from an efficiency standpoint, this will do what you want

dt << select rows where( Not( dt:Col 1 < someValue & dt:Col 2 == 1 ) );
dt:Col 1[dt << get selected rows] = "";
Jim
natalie_
Level V

Re: Removing values from a column

That's a good idea, too!  Thank you for your help.