Showing results for

- JMP User Community
- :
- Discussions
- :
- get rows where returning empty matrix

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 13, 2015 7:40 PM
(804 views)

I have a data table that I am trying to manipulate. I am using get rows where function to find where the first column equals a string, let's call it "aaa". When I use the software to do this, it works fine and two rows are selected, row 1 and row 2240. When I try to script this, the result is an empty matrix.

Here is the script I am using:

Names Default To Here( 1 );

dtx = Current Data Table();

noRows = N Rows( dtx );

ddd = dtx << Get Rows Where( Column( dtx, 1 ) == "aaa" );

and the result is

[](0, 1)

note that this returns a 1

Column( dtx, 1 ) [1] == "aaa"

Does anyone have any idea what I am doing wrong?

thanks in advance

Heather

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Solution

I looks like Get Rows Where wants a simpler argument, try one of these

dtx=open("$sample_data/big class.jmp");

c=column(dtx,3);

dtx<<get rows where( dtx:c == "F" );

or

dtx=open("$sample_data/big class.jmp");

dtx<<get rows where( dtx:sex == "F" );

the odd looking returned value, [](0, 1), is JMP's empty array of 0 rows and 1 column. the two examples return more rows, of one column:

[1, 2, 3, 4, 5, 9, 10, 11, 16, 17, 18, 19, 20, 28, 29, 35, 36, 38]

Craige

4 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I looks like Get Rows Where wants a simpler argument, try one of these

dtx=open("$sample_data/big class.jmp");

c=column(dtx,3);

dtx<<get rows where( dtx:c == "F" );

or

dtx=open("$sample_data/big class.jmp");

dtx<<get rows where( dtx:sex == "F" );

the odd looking returned value, [](0, 1), is JMP's empty array of 0 rows and 1 column. the two examples return more rows, of one column:

[1, 2, 3, 4, 5, 9, 10, 11, 16, 17, 18, 19, 20, 28, 29, 35, 36, 38]

Craige

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 14, 2015 3:50 AM
(615 views)

dtx=open("$sample_data/big class.jmp");

c=column(dtx,3);

dtx<<get rows where( dtx:c == "F" );

This did work, thank you both.

H

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 14, 2015 1:13 AM
(615 views)

A comparison of a *Column object* with a *string* will return always return false. In certain cases (or in general?) JMP must be expliticly told that you refer to a Column or to the Column values (I remember there has been a good thread about this maybe a little confusing difference but I can't find it now...)

You can access data with indices (as you showed above with Column( dtx, 1 ) [1] == "aaa"). In functions like G*et Rows Where()* that basically iterate through all column values, each value can be accessed with either of the below:

1) Column**(**dtx,**1****)[]** == "aaa" // Note the empty brackets

2) As Column**(**dtx,**1****)** == "aaa"

3) Or simplest with scoping colon as C Hales showed above

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 14, 2015 5:25 AM
(615 views)

cool. I didn't read the original question closely enough, and I'd forgotten about the empty [] anyway.

Craige