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
Djtjhin
Level IV

How to assign a list of values to specific list of rows (without for loop)

Is there a way to assign a list of values to specific rows in a column without for loop ?

 

For instance, is it possible to assign the "new values" in the script below to row 1,5,7 on the Weight column ? 

The script below doesn't work. I know one of the way to do this is to use for loop, but I wonder if there are other methods without for loops. 

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

index = [1,5,7];
new values = [11,22,33];
dt:weight[index] = new values;

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to assign a list of values to specific list of rows (without for loop)

No need to loop. This should work:

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

index = [1, 5, 7];
new values = [11, 22, 33];
dt[index, "weight"] = new values;

Used this great source as reference

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: How to assign a list of values to specific list of rows (without for loop)

No need to loop. This should work:

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

index = [1, 5, 7];
new values = [11, 22, 33];
dt[index, "weight"] = new values;

Used this great source as reference

 

-Jarmo
Djtjhin
Level IV

Re: How to assign a list of values to specific list of rows (without for loop)

Fantastic @jthi !! Learn something new today