You can send an empty Data Filter message to a data table, and the initial Data Filter window appears, showing the Add Filter Columns panel that lists all the variables in the data table.
Mode takes three arguments, all of which are optional: Select(bool), Show(bool), Include(bool). These arguments turn on or off the corresponding options. The default value for Select is true (1). The default value for Show and Include is false (0).
Add Filter() adds rows and builds the WHERE clauses that describe a subset of the data table. The basic syntax appears as follows:
df = dt << Data Filter(
Where( :sex == "M" ),
This script selects 13, 14, and 15-year-old males with a height greater than or equal to 52 and less than or equal to 65. In this filtered data, you can instead select the excluded ages by adding the Invert Selection message to the preceding script.
You can also use Add Filter() to select matching strings from columns with the Multiple Response property or Multiple Response modeling type.
df = dt << Data Filter(
This script selects rows with values in the Brush Delimited column that do not match either of the specified values ("Before Sleep", "Wake"). Other available scripting options include Match Any, Match All, Match Exactly, and Match Only. See “多重响应” in the Using JMP book for details about the Multiple Response property and the Multiple Response modeling type.
Clear takes no arguments and clears the data filter.
To prevent the data filter from appearing when the script is run, set Show Window to 0 as follows:
To specify which values to exclude, use the != operator. The following example excludes ages 16 and 17 from the filtered values.
df = dt << Data Filter(
To omit the Data Filter outline and red triangle menu, specify No Outline Box.
obj = dt << Data Filter(
No Outline Box( 1 )
biv = dt << Bivariate(
Automatic Recalc( 1 ),
dfObj = biv << Local Data Filter(
dfObj << Add Filter(
dist = Distribution(
Automatic Recalc( 1 ),
filter = dist << Local Data Filter(Add Filter( columns( :Region ) ));
rs = filter << Make Filter Change Handler( f );
Another option is to filter data from specific platforms or display boxes. Create a local data filter inside the Data Filter Context Box() function. This defines the context as the current platform or display box rather than the data table.
提示:The preceding script is part of a larger script that first builds the arrays required for a marker seg. To experiment with this script, open the Local Data Filter for Custom Graph.jsl sample script.
A context box can also contain several graphs with one local filter. The filtering then applies to both graphs. The following script creates two bubble plots and one data filter in one context box. See 图 9.5 for the output.
New Window( "Shared Local Filter",
dt << Data Filter( Local ),
Data filters can be hierarchical. One script might generate a data filter and a local data filter. The outer data filter for the data table determines which data is available for the local data filter. To illustrate this point, the following script produces both types of data filters as shown in 图 9.6.
提示:The following script is part of a larger script that first builds the arrays required for a marker seg. See the Local Data Filter for Custom Graph.jsl sample script for code that builds those arrays.
图 9.6 Data Filter Hierarchy