cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
saitcopuroglu
Level IV

selecting multiple rows defined by col var

Hi all,

I've found this script from one of the on-demand webcast data dt1 << Select Where( :Term == "Intercept" ); and adapting it to my data table the result is:

..... << Select Where( :SOURCE == "Facebook");


  • but how will I choose more than one (Facebook and Zoover and Tripadvisor...)
  • how will I clear the selection and make another selection
  • how will I invert the selection

Many thanks

8957_2015-06-18_12-41-04.png


1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: selecting multiple rows defined by col var

The example code below may give some ideas (the Wait(1) commands are only for demo purpose);

dt = New Table("demo", New Column("X", character, values({"a", "b", "c", "d", "q", "a", "b", "c", "d"})));

my_list = {"a", "c", "q"};

Wait(1);

dt << select where(Contains(my_list, :X));// Select all items in my_list

Wait(1);

dt << select where(Contains(my_list[1 :: 2], :X));//By default need to clear before making another selection

Wait(1);

dt << invert row selection; // Invert selection

Wait(1);

dt << clear select;// Clear selection

View solution in original post

5 REPLIES 5
ms
Super User (Alumni) ms
Super User (Alumni)

Re: selecting multiple rows defined by col var

The example code below may give some ideas (the Wait(1) commands are only for demo purpose);

dt = New Table("demo", New Column("X", character, values({"a", "b", "c", "d", "q", "a", "b", "c", "d"})));

my_list = {"a", "c", "q"};

Wait(1);

dt << select where(Contains(my_list, :X));// Select all items in my_list

Wait(1);

dt << select where(Contains(my_list[1 :: 2], :X));//By default need to clear before making another selection

Wait(1);

dt << invert row selection; // Invert selection

Wait(1);

dt << clear select;// Clear selection

saitcopuroglu
Level IV

Re: selecting multiple rows defined by col var

Thank you MS, I fell short to understand the second command, does it choose the 1st and 2nd values by order? No.. Does it select 1st and and 3rd by adding up 2?

What would be the command If I happen to have a second column (:Y) (with the second selection named as my_selection2) and would like to select the both together my_selection & my_selection2 ?

Many thanks for your support.

saitcopuroglu
Level IV

Re: selecting multiple rows defined by col var

I've understood the second command, it chooses the 1st and 2nd of my selection list and the third and fourth goes as [1 :: 2 :: 3 :: 4]?, many thanks

ms
Super User (Alumni) ms
Super User (Alumni)

Re: selecting multiple rows defined by col var

To adress multiple items of a list using an index [...] an matrix should be used.

my_list[1]; //First item

my_list[[1, 3]]; //First and third items

my_list[[1 2 3]]; //First to third items

my_list[1::3]; // Same thing

The double colon is short for Index(), i.e. it creates a matrix with a range of integers.

1::2 equals the matrix [1 2]

ms
Super User (Alumni) ms
Super User (Alumni)

Re: selecting multiple rows defined by col var

Exactly so! Use the "&" command to combine selection criteria.

dt << select where(Contains(..., :X) & Contains(..., :Y));