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

enter value in specific cell

Hello,

new little problem.

I would like to enter a value in a specific cell by

1) row name

2) column name

for example

I would like to enter value 25 in cell

     row (from col1) = 4

     col = SYN

Col1SYNMIS
110

2

15
320
4
5
6
7
8

best regards

Lionel

1 ACCEPTED SOLUTION

Accepted Solutions
robot
Level VI

Re: enter value in specific cell

Hi llupo0,

What are you trying to accomplish with your script?  I think this may be closer to what you are trying to do.

 

 

 

dt = New Table( "Little Class",
       Add Rows( 3 ),
       New Column( "name", Character, "Nominal", Set Values( {"KATIE", "LOUISE", "JANE"} ) ),
       New Column( "height", "Continuous", Set Values( [59, 61, 55] ) ),
       New Column( "weight", "Continuous", Set Values( [100, 150, 200] ) )
);
 
column_name = dt << get column names();
my_list = {62, 151};
For( i = 2, i <= N Items( column_name ), i++, // Add < sign.
       r = dt << Get Rows Where( :name == "LOUISE" );
       Column( i )[r] = my_list[i - 1]; // my_list has only two values, thus index [i - 1] is used for i = 3.
);

 

View solution in original post

10 REPLIES 10
robot
Level VI

Re: enter value in specific cell

Hi llupo0,

Try this:

 

 

// Create example table.
dt = New Table( "Little Class",
       Add Rows( 3 ),
       New Column( "name", Character, "Nominal", Set Values( {"KATIE", "LOUISE", "JANE"} ) ),
       New Column( "height", "Continuous", Set Values( [59, 61, 55] ) )
);
 
// Update value from row number.
dt:height[2] = 62;
 
// Update value from column value.
r = dt << Get Rows Where( :name == "LOUISE" );
dt:height[r] = 63;

 

KinKame
Level IV

Re: enter value in specific cell

Morning Robot

 

thank you for your feedback.

 

I see how you addressed the row. So in the same way I can also with a for loop have column movement.

tried but doesnt work :-(

 

 

dt = New Table( "Little Class",
       Add Rows( 3 ),
       New Column( "name", Character, "Nominal", Set Values( {"KATIE", "LOUISE", "JANE"} ) ),
       New Column( "height", "Continuous", Set Values( [59, 61, 55] ) ),
       New Column( "weight", "Continuous", Set Values( [100, 150, 200] ) ),
);
 
 
column_name = dt << get column names();
//my_list = {10, 20};
my_list = 777;
for(i=2, i=3, i++,
  r = dt << Get Rows Where( :name == "LOUISE" );
  dt:column_name= my_list
);

 

robot
Level VI

Re: enter value in specific cell

Hi llupo0,

What are you trying to accomplish with your script?  I think this may be closer to what you are trying to do.

 

 

 

dt = New Table( "Little Class",
       Add Rows( 3 ),
       New Column( "name", Character, "Nominal", Set Values( {"KATIE", "LOUISE", "JANE"} ) ),
       New Column( "height", "Continuous", Set Values( [59, 61, 55] ) ),
       New Column( "weight", "Continuous", Set Values( [100, 150, 200] ) )
);
 
column_name = dt << get column names();
my_list = {62, 151};
For( i = 2, i <= N Items( column_name ), i++, // Add < sign.
       r = dt << Get Rows Where( :name == "LOUISE" );
       Column( i )[r] = my_list[i - 1]; // my_list has only two values, thus index [i - 1] is used for i = 3.
);

 

KinKame
Level IV

Re: enter value in specific cell

trying to fill in value for certain column by row where row represents working weeks

so kind of weekly update record table.

ok it works! thank you. Also it is a good learning for me on how to manipulate table and data :-)

BTW,

how do you do to copy JSL code keeping color just like in JMP?

pmroz
Super User

Re: enter value in specific cell

>> BTW,

>> how do you do to copy JSL code keeping color just like in JMP?

Copy/paste the code from the JSL script editor into MS-Word.

Copy/paste the code from MS-Word to this forum.

// JSL Script

a = {"Hello", "World"};

msharp
Super User (Alumni)

Re: enter value in specific cell

It doesn't have to be word.  Any text editor that supports formatting, for example, I often copy and paste it into an email message since I always have Outlook open, but rarely have Word open.

Also here is how you would get your code working: (Just an example in debugging)

First, i=3 isn't a Boolean, if you meant i==3, this would never evaluate to true since i=2.  So I made the assumption you meant i<=3.

Next, you change my_list from a list to a number, so you need to reflect that in the for loop.  my_list becomes my_list.

Lastly, you need to be aware of the order of operations.  dt:column_name  This will first query the dt namespace to find a variable column_name.  It just so happens that there is indeed a column named name.  So then the will find the row in the column name, thus dt:column_name[1] == "KATIE", dt:column_name[2] == "LOUISE", ect.  However, your script will then die since "KATIE" is not a list or matrix, and there are no subscripts so kills it.  To keep order of operations correct you could simply change the code to below.  Alternatively you could use the column function to remove ambiguity.  Column(dt, i), or Column(dt, column_name) (which happen to be the same in this case since your column_name list is every column in the data table.)

column_name = dt << get column names();

//my_list = {10, 20};

my_list = 555;

for(i=2, i<=3, i++,

  r = dt << Get Rows Where( :name == "LOUISE" );

  dt:(column_name[i])[r] = my_list;

);

KinKame
Level IV

Re: enter value in specific cell

thank you very for your time explaining me my mistakes.

Learning from it

ENTHU
Level IV

Re: enter value in specific cell

Looking for help to assign list values to a cell.

I have a list obtained by using associative arrays on a column.

The number of values in the list is not known beforehand.Need to assign all values in the list to one specific cell.

So far I have tried this -

unique_vals = {};
unique_vals = Associative Array(dt:Test_Values) << Get Keys;
Column(dtout,"Col")[31] = unique vals;

But getting an error as follows -

Column "Col" requires character values{1} in access or evaluation of 'Bad Argument' 

If I use Column(dtout,"Col")[31] = unique vals[1];the error goes away but I need to assign all items in the list to that cell.

Any help appreciated.

txnelson
Super User

Re: enter value in specific cell

A JMP List is not one of the elements that can be defined for a data type for a column.  However, you can save the list as a character string, and write it to a character column.  Also, I believe that all you need to do to make your script work, is to use the Char() function to change the result from << get keys into a string

unique_vals = {};
unique_vals = Associative Array(dt:Test_Values) << Get Keys;
Column(dtout,"Col")[31] = Char( unique vals );
Jim