The `PivotFilter` class represents a single filter condition.

Format

R6Class object.

Details

The filter condition represented by a `PivotFilter` instance relates to one data frame variable/column and is of the form [ColumnName] IN c(Value1, Value2, Value3, ...). Often in a pivot table, each filter specifies only one data value, as typically each distinct data value exists in a separate row or column. The `PivotFilter` class contains methods to perform set based operations on filter values when combining filters.

Active bindings

variableName

The name of the column in the data frame that this filter applies to.

safeVariableName

The name of the column in the data frame that this filter applies to, surrounded by back-ticks if the name is not legal.

type

Either "ALL", "VALUES" or "NONE". "VALUES" is the most common type and means the data is filtered to a subset of values. "ALL" means there is no filtering, i.e. all values match. "NONE" means there can be no matching values/data.

values

The subset of values that this filter matches.

Methods

Public methods


Method new()

Create a new `PivotFilter` object.

Usage

PivotFilter$new(parentPivot, variableName = NULL, type = "ALL", values = NULL)

Arguments

parentPivot

The pivot table that this `PivotFilter` instance belongs to.

variableName

The name of the column in the data frame that this filter applies to.

type

Must be either "ALL", "VALUES" or "NONE". "VALUES" is the most common type and means the data is filtered to a subset of values. "ALL" means there is no filtering, i.e. all values match. "NONE" means there can be no matching values/data.

values

A single data value or a vector of multiple data values that this filter will match on.

Returns

A new `PivotFilter` object.


Method intersect()

Updates this filter by intersecting the values in this filter with the values from another `PivotFilter` object.

Usage

PivotFilter$intersect(filter)

Arguments

filter

A `PivotFilter` object.

Returns

No return value.


Method union()

Updates this filter by unioning the values in this filter with the values from another `PivotFilter` object.

Usage

PivotFilter$union(filter)

Arguments

filter

A `PivotFilter` object.

Returns

No return value.


Method replace()

Updates this filter by replacing the values in this filter with the values from another `PivotFilter` object.

Usage

PivotFilter$replace(filter)

Arguments

filter

A `PivotFilter` object.

Returns

No return value.


Method getCopy()

Create a copy of this `PivotFilter` object.

Usage

PivotFilter$getCopy()

Returns

A copy of this `PivotFilter` object.


Method asList()

Return the contents of this object as a list for debugging.

Usage

PivotFilter$asList()

Returns

A list of various object properties.


Method asJSON()

Return the contents of this object as JSON for debugging.

Usage

PivotFilter$asJSON()

Returns

A JSON representation of various object properties.


Method asString()

Return a representation of this object as a character value.

Usage

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

Arguments

includeVariableName

`TRUE` (default) to include the variable name in the string.

seperator

A character value used when concatenating multiple filter values.

Returns

A character summary of various object properties.


Method clone()

The objects of this class are cloneable with this method.

Usage

PivotFilter$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

pt <- PivotTable$new() # ... PivotFilter$new(pt, variableName="Country", values="England")
#> <PivotFilter> #> Public: #> asJSON: function () #> asList: function () #> asString: function (includeVariableName = TRUE, seperator = " ") #> clone: function (deep = FALSE) #> getCopy: function () #> initialize: function (parentPivot, variableName = NULL, type = "ALL", values = NULL) #> intersect: function (filter) #> replace: function (filter) #> safeVariableName: active binding #> type: active binding #> union: function (filter) #> values: active binding #> variableName: active binding #> Private: #> p_parentPivot: PivotTable, R6 #> p_safeVariableName: Country #> p_type: VALUES #> p_values: England #> p_variableName: Country