Filters in Displayr

From Displayr
Jump to: navigation, search

Most outputs in Displayr that have been computed using a Variable Set as an input can be filtered by selecting the object and choosing a filter from Home > Data Selection > Filter.

R Outputs

An R Output can refer to a variable called QFilter. Key properties of QFilter are:

  • It automatically updates when the filters change.
  • If no filters are applied, it takes a value of TRUE.
  • If a filter is applied, it has the same length as the number of non-deleted cases in the Data Set.
  • Where multiple filters are applied, a single variable is created (using an and operation).
  • The Variable Label is available as an attribute (i.e., attr(QFilter, "label")). Where there are multiple filters, they are concatenated as a list (e.g., "Male, 18 to 24 and Tall").
  • The Variable Name is available as an attribute (i.e., attr(QFilter, "label")). Where there are multiple names, they are concatenated in the same way as labels.

Approaches to using filters when writing R code

R code typically needs to do the following things when taking filters into account:

  • Filter the data. The data may either by passed to a function in some format, or extracted indirectly from the environment.
  • Clean the data in the filter.
  • Include the name or label of the filter in the output.

The most straightforward way to deal with these is to use an existing analysis as a template (e.g., flipMultivariates::LDA). Base R has a standard function for filtering data called subset.