Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

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

Topic Options

- Start Article
- 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
(4706 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

Solved Go to Solution

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- 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

4 REPLIES 4

Highlighted

- 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

Re: get rows where returning empty matrix

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

Re: get rows where returning empty matrix

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

Re: get rows where returning empty matrix

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

Craige