Spotfire® Enterprise Runtime for R

TERRAggregation_Boolean

In the Spotfire Custom Expressions dialog box, you can select the pre-defined expression TERRAggregation_Boolean from the Function list. This expression function sets the variable output to a scalar value of the TERR data type logical (TRUE or FALSE), which Spotfire converts to the corresponding Spotfire data type Boolean. The TERR script is called once for each group of data to be aggregated. No special handling for aggregation is necessary in your TERR script.

The expression function has at least two arguments.
Argument Argument description
A TERR script. The TERR script contains the following.
  • A number of variables using the naming convention that Spotfire requires: input1 to inputN, where inputN is the highest number of the specified inputs, numbered sequentally.
  • A TERR assignment operator (<-) that assigns the results of the TERR evaluation to an object named output (also using the naming convention that Spotfire requires).
Spotfire column names. Passed as additional arguments, these are the data column names that input1 to inputN represent. All columns must be the same length.
The output type is returned from TERR and converted by Spotfire.
Returned by TERR Converted in Spotfire
A single aggregated value of data type logical. A single aggregated value of data type Boolean.

TERRAggregation_Boolean example

This example data set gives information on the makes of cars taken from the April, 1990 issue of Consumer Reports (pages 235-255). This data set contains 6 columns for 61 cars (rows). You can find the sample data set in Car data set for Spotfire examples.
Tip: You can copy (CTRL+C) the contents of the sample data table and paste it (CTRL+V) into the Spotfire user interface.
In the expression function, determine which types of cars have an aggregated value of mileage over 30.
TERRAggregation_Boolean("output <- any(input1 > 30)",[Mileage]) OVER ([Type])

The resulting bar chart in Spotfire, with Color by set to the aggregation results, shows the following.


TERRAggregation_Boolean

Important: Spotfire autocorrects the function case or name to that of built-in Spotfire function names. (For example, TERR contains the function max, and Spotfire contains the function Max. ) You must overwrite this autocorrection manually to ensure that you use the TERR function case and name in your expression function.

See Embedding the Contents of a Script in an Expression Function for a detailed procedure for creating an expression function.