cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
timloaami
Level I

Data Filter stopped in a for-loop

I am writing a for-loop script to search for the x-values of the y-maximum peaks in some parts of the spectra collected in different experimental conditions. However, the Data Filter stopped after running one round by the warning "Your selection was changed in another window." How can I get rid of this warning so that the script can be run smoothly to complete the for-loop?

 

Let me use Big Class.jmp example to demonstrate the problem. The objective is to show the subset of data corresponding to the people having the maximum weight (y-maximum value) in several ranges of heights (x-value ranges, say 55-60, 60-62, 62-65) by different ages (similar to experimental conditions).

 

The x-value ranges are grouped by two lists, one containing the lower limits & another one the upper limits. The maximum is found by Col Maximum with Data Filter. The calculation is looped for several x-value ranges along the lists. However, after running for i=1, the loop stops and the Data Filter warning appears. How to get rid of it to let the script complete the for-loop?

 

 

Names Default To Here( 1 );
ListA = {55, 60, 62};
ListB = {60, 62, 65};
for(i=1, i<=3, i++,
dt = Data Table( "Big Class" );
Current Data Table (dt);
a = ListA[i];
b = ListB[i];
dt << Data Filter(Add Filter(columns(:height), where(:height > a & :height < b)), Mode( Select( 0 ), Show( 0 ), Include( 1 )), Show Window(0), Auto Clear(1));
dt << select where (col maximum(:weight, :age, Excluded()) == :weight & :height > a & :height < b);
dt << subset(selected rows(1), columns({"name", "age", "sex", "height", "weight"}));
dt << Clear Row States;
dt << Clear Select();
);

 

 

1 REPLY 1
txnelson
Super User

Re: Data Filter stopped in a for-loop

I believe the simplified JSL below gives you what you want.

Names Default To Here( 1 );
dt = 
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
Open( "$SAMPLE_DATA/big class.jmp" );

ListA = {55, 60, 62};
ListB = {60, 62, 65};

	
For( i = 1, i <= 3, i++,
	a = ListA[i];
	b = ListB[i];
	Current Data Table( dt );
	theMax = Col Maximum( If( :weight & :height > a & :height < b, :weight, . ) );
	dt << select where( theMax == :weight & :height > a & :height < b );
	If( N Rows( dt << get selected rows ) > 0,
		dt << subset( selected rows( 1 ), columns( {"name", "age", "sex", "height", "weight"} ) )
	);
	dt << Clear Row States;
	Wait( 0 );
);
Jim