Choose Language Hide Translation Bar

## [Scripting : local data filter in for loop for continuous distribution]

Hi,

I'm a still a beginner, hope I'll progress with this problem !

I have a recurrent column named "median_range_mm" then "median_range_mm 2" then "median_range_mm 3 ..."

And an associated column called "target_status" then" target_status_2" .....

I would like to plot a continuous distribution with all median range 1, 2 , 3...  on the same window. BUT I want to filter all the cell from a median range that it has a target status different to 5.

Hope I am clear. This the code, I don't know how to write the condition of filter for target status in a loop "for".

``````dt = Current Data Table();
/renaming columnsFor( i = 1, i <= 716, i++, For( j = 0, j <= 65, j++, If( i == 1, Column( i ) << set name( "EVENT_BEGIN_OF_CAPTURE" ), i == 10, Column( i ) << set name( "Temperature" ), i == 16 + 11 * j, Column( i ) << set name( "target_status" ), i == 17 + 11 * j, Column( i ) << set name( "median_range_mm" ), ) ))
// for the first ranging column
valMax = Max( :Temperature[dt << get rows where( :target_status == 5 )] ); //max selection
For( d = 3, d <= N Rows( dt ), d++,
val1 = Column( "Temperature" )[d];
val2 = Column( "Temperature" )[d + 1];
dt << select where( val2 - val1 <= 0.1 * valMax ); //stability
);
// plot of the first ranging
New Window( "Only plot median range with a stable temperature",
H List Box(
Distribution(
Uniform Scaling( 1 ),
Continuous Distribution(
Column( :median_range_mm ),
Show Percents( 1 ),
Show Counts( 1 ),
Customize Summary Statistics( Minimum( 1 ), Maximum( 1 ), Median( 1 ), Set Alpha Level( 0.05 ) ),
/* it is the first column so I can write  : "target_status" to call the column */				                                                    Local Data Filter( Add Filter( columns( :target_status ), Where( :target_status == 5 ) ) );
)
);
// looking for the first max value of the ranging
maxValue = Max( :median_range_mm[dt << get rows where( :target_status == 5 )] );
minValue = Min( :median_range_mm[dt << get rows where( :target_status == 5 )] );

// Then look on the others columns
For( p = 2, p <= 64, p++,
nom = "median_range_mm " || Char( p ); // look at ranging median_range_mm 1, 2, 3 ...
col = Column( nom );
name = "target_status " || Char( p ); // look at target status associated
tgt = Column( name );
//dt << get rows where( Column( name ) == 5); // doesn't work
maxValueVar = Max( Column( nom )[dt << get rows where( Column( name ) == 5 )] );
minValueVar = Min( Column( nom )[dt << get rows where( Column( name ) == 5 )] );
If(
maxValueVar > maxValue, maxValue = maxValueVar,
minValueVar < minValue, minValue = minValueVar
);
);

For( g = 2, g <= 64, g++,
nom = "median_range_mm " || Char( g );
col = Column( nom );                        /* there is difficutie*/                                        name = "target_status " || Char( g );
tgt = Column( name );
valueMax = Max( :Temperature );
For( h = 3, h <= N Rows( dt ), h++,
value1 = Column( "Temperature" )[h];
value2 = Column( "Temperature" )[h + 1];
dt << select where( value2 - value1 <= 0.1 * valueMax ); // this is for a plot with a stable temperature
);

Distribution(
Uniform Scaling( 1 ),
Continuous Distribution(
Column( col ),
Show Percents( 1 ),
Show Counts( 1 ),
Customize Summary Statistics( Minimum( 1 ), Maximum( 1 ), Median( 1 ), Set Alpha Level( 0.05 ) ),                                        /* there is the difficultie*/                                        /* I don't want to call all the columns " target_status 2 , 3 , 4 .... */                                                                   Local Data Filter(
Add Filter( columns( Column( tgt ), Where( Column( tgt ) == 5 ) ) );

)
)
);
);
)
);``````

Cheers

## Re: [Scripting : local data filter in for loop for continuous distribution]

Some general ideas...

First, I think that the data filter is a wonderful device when interactive manipulation of the row states is called for. It seems that in your case, though, row states are controlled instead by the explicit loops, so I would directly manipulate the row states with the script, not a filter.

Second, you can use any Boolean expression as the argument to the data table message << Select Where( Boolean ). Follow this message with the << Exclude message. The row state will determine that your platform (Distribution, for example), will not include these observations.

Third, the platform launch message can include a Where( Boolean ) argument that might be of use in this problem.

Finally, I am not sure about the purpose of the two loops inside the New Window() function. It is probably best to move them outside of the functfion and use the Append() message to add more platforms to the window.

Learn it once, use it forever!