cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar

JSL select rows near the maximum value of a column

Hi,

I have a data series shown in the screenshot below, and try to select only the data in the range of "x +/- 0.3" with the center at the maximum value of "y".

I got an error message "The argument to SelectWhere did not evaluate to true or false, it is [0]..." from the highlighted line, as shown below. What is puzzling is that the last line worked when only 1 condition is applied.

What is wrong with the script in line 6? Thanks! 

  

 

CurseOfLizard13_0-1659708437088.png

 

Names Default To Here( 1 );
dt = current data table();
mxrow = dt << get rows where (:y == col max(:y) );
mxx = dt:x[mxrow];
print (mxrow, mxx);
dt << select where (:x < mxx + 0.3 & :x > mxx - 0.3);
dt << select where (:x < mxx + 0.3);

 

4 REPLIES 4
Thierry_S
Super User

Re: JSL select rows near the maximum value of a column

Hi,

Try using the following syntax:

dt << select where (eval (mxx - 0.3) <= :x < eval (mxx + 0.3));

Best,

TS

Thierry R. Sornasse
jthi
Super User

Re: JSL select rows near the maximum value of a column

I think JMP doesn't like that you are comparing matrices to single numbers.

Names Default To Here(1);

dt = New Table("Untitled", Add Rows(3), New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3])));

max_x = [2];
dt << Select Where(:Column 1 > max_x); // will print message to log

wait(2);

min_x = 2;
dt << Select Where(:Column 1 < min_x);
-Jarmo
pauldeen
Level VI

Re: JSL select rows near the maximum value of a column

So to get around your problem, just index into the first value of your mxx:

Names Default To Here( 1 );
dt = current data table();
mxrow = dt << get rows where (:y == col max(:y) );
mxx = (dt:x[mxrow])[1]; //Index into the matrix and extract the first item
print (mxrow, mxx);
dt << select where (:x < mxx + 0.3 & :x > mxx - 0.3);
dt << select where (:x < mxx + 0.3);
vince_faller
Super User (Alumni)

Re: JSL select rows near the maximum value of a column

If there happen to be multiple rows that are at max you could do

 

Names default to here(1);
dt = New Table( "Test",
	Add Rows( 46 ),
	New Column( "x",
		Set Values(
			[1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4,
			2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9,
			4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5, 5.1, 5.2, 5.3, 5.4,
			5.5]
		)
	),
	New Column( "y",
		Set Values(
			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
			1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
			1]
		)
	)
);
mxrow = dt << get rows where (:y == col max(:y) );
mxx = dt:x[mxrow];
dt << select where (Any(mxx - 0.3 <= :x < mxx + 0.3));

gb = dt << Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :x ), Y( :y ) ),
);

vince_faller_0-1660671897366.png

 

The unselected point on the second peak is because of floating error.  

Vince Faller - Predictum