Learn R Programming

pivottabler (version 0.4.0)

PivotFilters: A class that defines a set of filter conditions

Description

The PivotFilters class allows multiple filter conditions relating to different data frame columns to be combined, i.e. a PivotFilters object can contain multiple PivotFilter objects.

Usage

PivotFilters

Arguments

Value

Object of R6Class with properties and methods that define a set of filter conditions.

Format

R6Class object.

Fields

parentPivot

Owning pivot table.

count

The number of PivotFilter objects in this PivotFilters object.

filters

The PivotFilter objects in this PivotFilters object.

isALL

If TRUE, this PivotFilters object matches all data.

isNONE

If TRUE, this PivotFilters object matches no data.

filteredVariables

A list of the variables that are filtered by this PivotFilters object.

filteredValues

A list of the criteria values for each of the variables filtered by this PivotFilters object.

Methods

Documentation

For more complete explanations and examples please see the extensive vignettes supplied with this package.

new(...)

Create a new pivot calculation, specifying the field values documented above.

getFilter(variableName=NULL)

Find a filter with the specified variable name.

isFilterMatch(variableNames=NULL, variableValues=NULL)

Tests whether these filters match the specified criteria.

setFilters(filters=NULL, action="replace")

Update the value of this PivotFilters object with the filters from the specified PivotFilters object, either unioning, intersecting or replacing the filter criteria.

setFilter(filter=NULL, action="replace")

Update the value of this PivotFilters object with the specified PivotFilter object, either unioning, intersecting or replacing the filter criteria.

setFilterValues(variableName=NULL, type=NULL, values=NULL, action="replace")

Update the value of this PivotFilters object with the specified criteria, either unioning, intersecting or replacing the filter criteria.

addFilter()

Directly add a PivotFilter object to this PivotFilters object.

getFilteredDataFrame(dataFrame=NULL)

Filters the specified data frame and returns the results as another data frame.

getCopy()

Get a copy of this set of filters.

asList()

Get a list representation of this PivotFilters object.

asJSON()

Get a JSON representation of this PivotFilters object.

asString(includeVariableName=TRUE, seperator=", ")

Get a text representation of this PivotFilters object.

Examples

Run this code
# NOT RUN {
pt <- PivotTable$new()
# ...
# PivotFilters constructor allows a filter to be defined
filters <- PivotFilters$new(pt, variableName="Year", values=2017)
# Create a new filter
filter <- PivotFilter$new(pt, variableName="Country", values="England")
# Combine the filters
filters$setFilter(filter)
# filters now contains criteria for both Year and Country
# Now add another filter, this time via an alternative method
filters$setFilterValues(variableName="Product", values="Cadbury Dairy Milk
Chocolate 100g")
# filters now contains criteria for Year, Country and Product
# }

Run the code above in your browser using DataLab