get rows where returning empty matrix<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />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
Re: get rows where returning empty matrixcool. I didn't read the original question closely enough, and I'd forgotten about the empty [] anyway.
Re: get rows where returning empty matrix
dtx=open("$sample_data/big class.jmp");
c=column(dtx,3);
dtx<
This did work, thank you both.
H
Re: get rows where returning empty matrixA 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 Get 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
Re: get rows where returning empty matrixI 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<
or
dtx=open("$sample_data/big class.jmp");
dtx<
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]