cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
EDW
EDW
Level I

JSL - Replacing Column Values with Vector

I'm attempting to script a function that replaces a range of column values with a vector of equal dimension. My code below either rejects the argument entirely or just changes the entire cell value to the vector, rather than spanning the range. I can imagine creating a "for loop" that would iterate through each row and and index the vector accordingly, but writing one value at a time seems inefficient, especially since my actual spreadsheet has about 100k rows. Here is a simple example of my process:

 

Names Default To Here( 1 );

//Example Table
dt = New Table( "Example", Add Rows( 10 ), New Column( "Test", <<Set Each Value( 1 ) ) );

Wait( 1 ); //Demonstration Purposes

x = [10, 10, 10];
:Test[3 :: 5] = x;

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: JSL - Replacing Column Values with Vector

Here is an old school way to do this:

Names Default To Here( 1 );

//Example Table
dt = New Table ("Example",
	Add Rows ( 10 ),
	New Column ( "Test", << Set Each Value ( 1 ) );
);

Wait (1); //Demonstration Purposes

x = [10, 10, 10];
start=3;
for(i=1,i<=nrows(x),i++,
	:test[i+start-1]=x[i]
);
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: JSL - Replacing Column Values with Vector

Here is an old school way to do this:

Names Default To Here( 1 );

//Example Table
dt = New Table ("Example",
	Add Rows ( 10 ),
	New Column ( "Test", << Set Each Value ( 1 ) );
);

Wait (1); //Demonstration Purposes

x = [10, 10, 10];
start=3;
for(i=1,i<=nrows(x),i++,
	:test[i+start-1]=x[i]
);
Jim

Recommended Articles