Subscribe Bookmark RSS Feed

Script - Filter

seyberg

Community Trekker

Joined:

Nov 17, 2011

I'm having an issue with scripting a data filter.  I want to create a script where I make a data filter which excludes/hides some data, runs a graphing function, unexcludes/unhides all data, then closes the filter window.

What I have so far is,

obj = Current Data Table() << Data Filter( Add Filter(  /*     Filter Conditions        */ ));

/*    Graphing Function     */

obj << Clear;

wdw = window("Data Filter <File Name>");

wdw << closewindow();

This is a working solution but only while the file name is exactly as created.  Is there a way to generalize the file name?  Alternately, another method of closing the data filter window would also fulfil my needs.

5 REPLIES
David_Burnham

Super User

Joined:

Jul 13, 2011

First of all sorry if I am misunderstanding what you are trying to do, but I get the sense that you are trying to use the data filter to automate the exclusion of data points in preparation for making a graph without using it interactively.  The data filter is just a convenient user-interface tool for controlling the hide and exclude row states - if you are not using the filter interactively it may be easier to just script these row states directly:

obj = Current Data Table();

sel = obj << Select Where( /* filter conditions */ );

sel << Exclude;  /* exclude selection */

/* graphing function */

sel << Exclude; /* toggle-off exclude selection */

Dave

-Dave
David_Burnham

Super User

Joined:

Jul 13, 2011

For the purposes of correctness, the data filter operates the reverse to row states (i.e. it uses show and include whereas the row states are hide and exclude) so in my example above the selection should be inverted:

sel = obj << Select Where( /* filter conditions */ );

sel << Invert Row Selection;

sel << Exclude;  /* exclude selection */

-Dave
seyberg

Community Trekker

Joined:

Nov 17, 2011

Dave@Pega-Analytics wrote:

I get the sense that you are trying to use the data filter to automate the exclusion of data points in preparation for making a graph without using it interactively.

That is correct.  The ideal is for another JMP user to reach the end analysis from any table form (exclusions, selections), run graphs, then clear back to the table default.  I'm having trouble getting this script to recognize multiple conditions, at least by writing it in as I would in the filter function like so.

Data Filter( Add Filter(

        columns( :Condition 1, :Condition 2),

        Where( :Condition 1 == {"A", "B"} ),

        Where( :Condition 2 == {"C", "D"}) ),

Mode( Select( 0 ), Show( 1 ), Include( 1 ) ) );

How would this filter be translated into script?  And how do you clear selection?

David_Burnham

Super User

Joined:

Jul 13, 2011

The code that you are writing is generated from the data filter by selecting the option Script>Save Script to Script Window e.g.

Current Data Table() << Data Filter(

          Location( {638, 47} ),

          Add Filter( columns( :age, :sex ), Where( :age == 12 ), Where( :sex == "F" ) )

);

To get a JSL specification of the where clause you can use the option Save Where Clause>to Script Window e.g.

Select Where( :age == 12 & :sex == "F" );

The programmatic equivalent of pressing the Clear button on the data filter is to write

obj << Clear Row States;

where obj is a reference to the data table.

Dave

-Dave
seyberg

Community Trekker

Joined:

Nov 17, 2011

Thanks a ton Dave!  I think I have it figured out from there.