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
- :
- Finding row index as a number

Topic Options

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

Highlighted

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

Jan 13, 2016 10:27 AM
(4680 views)

hi all.

I need to find row index when column2 =0

and then use the row number in subset.

when I use "select where" or "get where" it doesn't give me the index as a number.

`dt<<get rows where( :column (2)==0);`

1 ACCEPTED SOLUTION

Accepted Solutions

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

Your result indicates there were no rows meeting your criteria. If you know there are rows with 0 in them, it may be that your column is character data type and the comparison is numeric... either put quotes around 0 in your comparison, or change the data type of the column to Numeric.

5 REPLIES 5

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

Re: Finding row index as a number

Slight modification to your syntax:

`rmat = dt << get rows where (as column(2) == 0);`

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

Re: Finding row index as a number

it shows:

rmat = [](0, 1);

what does this mean? I need just a number. for example 90. (means in row #90)

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

Re: Finding row index as a number

Run this:

```
dt=New Table( "example table",
Add Rows( 12 ), New Column( "A column", Numeric, "Continuous",
Set Values( [1, 1, 1, 10, 0, 1, 1, 1, 0, 1, 0, 1] ) ));
rmat = dt << get rows where (as column(1) == 0);
```

in the log you'll see this:

**[5, 9, 11]**

this is a list of rows where the first column was equal to 0;

JMP Systems Engineer, Pharm and BioPharm Sciences

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

Re: Finding row index as a number

rmat is a row matrix. To get the number of rows you can write **n = NRows(rmat)**. The first row number will be **rmat[1]**, the second **rmat[2]** up to** rmat**. If you want to look up corresponding values in another column, just for these rows you can write

-Dave

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