The `PivotBatch` class represents one combination of data, variables and calculations that are needed when calculating the values of cells in a pivot table.

Format

R6Class object.

Details

The combination of data name and variable names defines a batch. When the batch is calculated, the calculations specified in the batch are evaluated against the specified data, with the data being grouped by the variables specified in the batch. Individual result values can then be retrieved from the batch. See the "Performance" vignette for details.

Active bindings

batchId

The unique identifier for the batch.

batchName

The unique name of the batch.

compatibleCount

The number of pivot cell calculations that this batch supports.

evaluated

TRUE if this batch has been evaluated.

results

The results (a data frame) of the evaluation of the batch

asString

A text description of the batch.

Methods


Method new()

Create a new `PivotBatch` object.

Usage

PivotBatch$new(
  parentPivot = NULL,
  batchId = 0,
  dataName = NULL,
  variableNames = NULL,
  values = NULL,
  calculationName = NULL,
  calculationGroupName = NULL
)

Arguments

parentPivot

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

batchId

The unique identifier for the batch.

dataName

The name of the data frame (as specified in `pt$addData()`) that this batch relates to.

variableNames

Specifies the combination of variable names (i.e. dimensionality) of the batch.

values

A list specifying the distinct list of values for each variable, i.e. `list(varName1=values1, varName2=values2, ...)`. `values` is not currently used and does not affect the batch compatibility logic.

calculationName

The first calculation added to this batch. Does not affect the batch compatibility logic.

calculationGroupName

The calculation group of the first calculation added to this batch. Does not affect the batch compatibility logic.

Returns

A new `PivotBatch` object.


Method isCompatible()

Determine whether a combination of data and variables is compatible with this batch.

Usage

PivotBatch$isCompatible(dataName = NULL, variableNames = NULL)

Arguments

dataName

The name of the data frame (as specified in `pt$addData()`).

variableNames

Specifies the combination of variable names (i.e. dimensionality)..

Returns

`TRUE` or `FALSE`.


Method addCompatible()

Add a new set of values or a new calculation to the batch. with this batch.

Usage

PivotBatch$addCompatible(
  values = NULL,
  calculationName = NULL,
  calculationGroupName = NULL
)

Arguments

values

A list specifying the distinct list of values for each variable, i.e. `list(varName1=values1, varName2=values2, ...)`. `values` is not currently used and does not affect the batch compatibility logic.

calculationName

The calculation to add to the batch. Does not affect the batch compatibility logic.

calculationGroupName

The calculation group of the calculation to add to the batch. Does not affect the batch compatibility logic.

Returns

No return value.


Method getCalculationInternalName()

Find the internal name of a calculation in the batch.

Usage

PivotBatch$getCalculationInternalName(
  calculationName = NULL,
  calculationGroupName = NULL
)

Arguments

calculationName

The name of the calculation to find.

calculationGroupName

The calculation group of the calculation to find.

Returns

The internal name of the calculation in the batch.


Method evaluateBatch()

Carry out grouping and calculations to evaluate the batch.

Usage

PivotBatch$evaluateBatch()

Returns

No return value.


Method getSummaryValueFromBatch()

Retrieve one calculation value from the batch, typically for the value of one cell in a pivot table.

Usage

PivotBatch$getSummaryValueFromBatch(
  filters = NULL,
  calculationName = NULL,
  calculationGroupName = NULL
)

Arguments

filters

A `PivotFilters` instance that specifies which value to retrieve. This filters object is a combination of the row, column and calculation filters.

calculationName

The name of the calculation value to retrieve.

calculationGroupName

The calculation group of the calculation to retrieve.

Returns

A single calculation value.


Method clone()

The objects of this class are cloneable with this method.

Usage

PivotBatch$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# This class should only be created by the pivot table.
# It is not intended to be created outside of the pivot table.