cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Set Column Value for Selected Rows Using a Data Filter Documentation
txnelson
Super User

This addin allows the user to use a data filter to make simple or complex row selections, and then specify the column to write to and the value to write to the selected rows.  While this is no different than selecting rows with a data filter, and then pasting a value into one of the selected cell, which will replicate the action to all selected rows, the addin is a more friendly method, allowing the user to select the column to be changed, and to type into an input field, the value to be written to the selected rows.

This is a great way to create a binning column for bins determined by a complex combination of columns

Here is an example using the Big Class data table:

10810_pastedImage_0.png

Just specify the column to be changed....in this case a new column called "Bin" was been added to the data table.  And then use the Data Filter to do the selection.  Finally specify the value to be written to the column "Bin" for the selected rows.

10813_pastedImage_0.png

Once the "Set Value" button is clicked on, the values are written to the data table

10812_pastedImage_2.png

Comments

Thank you, thank you, thank you! You have saved my life and career!

Urszula

Urszula_0-1724934660381.png

Hello, I would like to use your add-in, but I'm getting this message after opening it in JMP 17.0.0. Could you help me with this?

bb101

@txnelson Thanks for the handy way to annotate data. I'd like to achieve this with jsl. I hope you can help.

 

I am able to select the rows based on lists using Select Where. I tried the getRowsWhere to assigtn the value of :LABEL. This approach did not work. 

I'd like to use Select Where and then set the value of :LABEL in all selected rows to a constant string. 

//provision a column for annotating the LABEL information for the dataset
column_list = dt << Get Column Names(string);
if (!contains(Column_list, "LABEL_Note"),
dt << New Column( "LABEL_Note",Character, << Set Each value("Production"));
);
//Find LABEL in the list and label them labelrows = dt << getRowsWhere( Contains(labelList, :LABEL)); Column(dt, "LABEL_Note")[labelrows] = "List"; //Find LABEL in the list and label them labelrows = dt << getRowsWhere( Contains(labelReturnedList, :LABEL)); Column(dt, "LABEL_Note")[labelrows] = "Returned"; //Find Label in the list dt << Select Where( Contains(labelList, :LABEL));

Thank you

 

txnelson

Here is an example using Get Rows Where

txnelson_0-1747082741582.png

names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

dt << new column("Gender", character);

theRows = dt << get rows where(:sex == "F");
:Gender[theRows] = "Female";

theRows = dt << get rows where(:sex == "M");
:Gender[theRows] = "Male";

I would look to validate what is returned from the Get Rows Where

bb101

Thank you @txnelson! I confirmed that the getRowsWhere call return contained the correct rows. Using your example I modified the assignment operations. The jsl below shows a case where a group of rows get a common label and a case where a for loop is used to assign labels from a list to groups of rows. The change that moved this forward was in the assignment operation. 

 

column_list = dt << Get Column Names(string);
if (!contains(Column_list, "LABEL_Note"),
      dt << New Column( "LABEL_Note",Character, << Set Each value("Production Data"));
      //Find LABEL in the list and label them
      labelrows = dt << getRowsWhere( Contains(labelList, :LABEL));
      :LABEL_Note[labelrows] = "List";

      For( i = 1, i <= N Items( labelReturnedList), i++,
            labelreturnedrows = dt << getRowsWhere( Contains(labelReturnedList[i], :LABEL));
            :LABEL_Note[labelreturnedrows ] = labelReturnedList[i];         
      );    
);

 

Starting in JMP 18, you should be able to set each level of your indicator column in a single line of JSL, for example:

dt = Open("$SAMPLE_DATA/Big Class.jmp");
col = dt << New Column("Label", "Character");
col[Where(:age <= 14)] = "Age <= 14";
col[Where(:age > 14)] = "Age > 14";

This should be no slower than using Get Rows Where, and will probably be noticeably faster in most situations.

Recommended Articles