The `PivotCells` class contains all of the `PivotCell` instances that comprise the body of a pivot table.

`R6Class`

object.

`rowCount`

The number of rows in the pivot table (excluding column headings).

`columnCount`

The number of columns in the pivot table (excluding column headings).

`rowGroups`

A list of the leaf-level data groups on the rows axis.

`columnGroups`

A list of the leaf-level data groups on the columns axis.

`rows`

A list of the rows in the pivot table. Each element in this list is a list of `PivotCell` objects comprising the row.

`all`

A list of the cells in the pivot table. Each element in this list is a `PivotCell` object.

`getColumnGroup()`

Get the leaf-level data group that is associated with a specific column or columns in the pivot table.

`getRowGroup()`

Get the leaf-level data group that is associated with a specific row or rows in the pivot table.

`setGroups()`

An internal method used when building the cell structure of the pivot table.

`getCell()`

Get the cell at the specified row and column coordinates in the pivot table.

`setCell()`

Set the cell at the specified row and column coordinates in the pivot table.

`r`

Row number of the cell to retrieve.

`c`

Column number of the cell to retrieve.

`cell`

A `PivotCell` object to set into the pivot table cells.

`getCells()`

Retrieve cells by a combination of row and/or column numbers. See the "Finding and Formatting" vignette for graphical examples.

```
PivotCells$getCells(
specifyCellsAsList = TRUE,
rowNumbers = NULL,
columnNumbers = NULL,
cellCoordinates = NULL,
excludeEmptyCells = FALSE,
groups = NULL,
rowGroups = NULL,
columnGroups = NULL,
matchMode = "simple"
)
```

`specifyCellsAsList`

Specify how cells are retrieved. Default `TRUE`. More information is provided in the details section.

`rowNumbers`

A vector of row numbers that specify the rows or cells to retrieve.

`columnNumbers`

A vector of row numbers that specify the columns or cells to retrieve.

`cellCoordinates`

A list of two-element vectors that specify the coordinates of cells to retrieve. Ignored when `specifyCellsAsList=FALSE`.

`excludeEmptyCells`

Default `FALSE`. Specify `TRUE` to exclude empty cells.

`groups`

A `PivotDataGroup` object or a list of `PivotDataGroup` objects on either the rows or columns axes. The cells to be retrieved must be related to at least one of these groups.

`rowGroups`

A `PivotDataGroup` object or a list of `PivotDataGroup` objects on the rows axis. The cells to be retrieved must be related to at least one of these row groups. If both `rowGroups` and `columnGroups` are specified, then the cells to be retrieved must be related to at least one of the specified row groups and one of the specified column groups.

`columnGroups`

A `PivotDataGroup` object or a list of `PivotDataGroup` objects on the columns axis. The cells to be retrieved must be related to at least one of these column groups. If both `rowGroups` and `columnGroups` are specified, then the cells to be retrieved must be related to at least one of the specified row groups and one of the specified column groups.

`matchMode`

Either "simple" (default) or "combinations"

"simple" specifies that row and column arguments are considered separately (logical OR), e.g. rowNumbers=1 and columnNumbers=2 will match all cells in row 1 and all cells in column 2.

"combinations" specifies that row and column arguments are considered together (logical AND), e.g. rowNumbers=1 and columnNumbers=2 will match only the cell single at location (1, 2).

Arguments `rowNumbers`, `columnNumbers`, `rowGroups` and `columnGroups` are affected by the match mode. All other arguments are not.

When `specifyCellsAsList=TRUE` (the default):

Get one or more rows by specifying the row numbers as a vector as
the rowNumbers argument and leaving the columnNumbers argument set
to the default value of `NULL`, or

Get one or more columns by specifying the column numbers as a vector
as the columnNumbers argument and leaving the rowNumbers argument
set to the default value of `NULL`, or

Get one or more individual cells by specifying the cellCoordinates
argument as a list of vectors of length 2, where each element in the
list is the row and column number of one cell,

e.g. `list(c(1, 2), c(3, 4))` specifies two cells, the first located
at row 1, column 2 and the second located at row 3, column 4.

When `specifyCellsAsList=FALSE`:

Get one or more rows by specifying the row numbers as a vector as the
rowNumbers argument and leaving the columnNumbers argument set to the
default value of `NULL`, or

Get one or more columns by specifying the column numbers as a vector
as the columnNumbers argument and leaving the rowNumbers argument set
to the default value of `NULL`, or

Get one or more cells by specifying the row and column numbers as vectors
for the rowNumbers and columnNumbers arguments, or

a mixture of the above, where for entire rows/columns the element in the
other vector is set to `NA`, e.g. to retrieve whole rows, specify the row
numbers as the rowNumbers but set the corresponding elements in the
columnNumbers vector to `NA`.

`findCells()`

Find cells matching specified criteria. See the "Finding and Formatting" vignette for graphical examples.

```
PivotCells$findCells(
variableNames = NULL,
variableValues = NULL,
totals = "include",
calculationNames = NULL,
minValue = NULL,
maxValue = NULL,
exactValues = NULL,
valueRanges = NULL,
includeNull = TRUE,
includeNA = TRUE,
emptyCells = "include",
outlineCells = "exclude",
rowNumbers = NULL,
columnNumbers = NULL,
cellCoordinates = NULL,
groups = NULL,
rowGroups = NULL,
columnGroups = NULL,
rowColumnMatchMode = "simple",
cells = NULL,
lowN = NULL,
highN = NULL
)
```

`variableNames`

A character vector specifying the name/names of the variables to find. This is useful generally only in pivot tables with irregular layouts, since in regular pivot tables every cell is related to every variable.

`variableValues`

A list specifying the variable names and values to find, e.g. `variableValues=list("PowerType"=c("DMU", "HST"))`.

Specify "**" as the variable value to match totals for the specified variable.

Specify "!*" as the variable value to match non-totals for the specified variable.

NB: The totals/non-totals criteria above won’t work when visual totals are used.`totals`

A word that specifies how totals are matched (overrides the finer settings above) - must be one of "include" (default), "exclude" or "only".

`calculationNames`

A character vector specifying the name/names of the calculations to find.

`minValue`

A numerical value specifying a minimum value threshold.

`maxValue`

A numerical value specifying a maximum value threshold.

`exactValues`

A vector or list specifying a set of allowed values.

`valueRanges`

A vector specifying one or more value range expressions which the cell values must match. If multiple value range expressions are specified, then the cell value must match any of one the specified expressions.

`includeNull`

Specify TRUE to include `NULL` in the matched cells, FALSE to exclude `NULL` values.

`includeNA`

Specify TRUE to include `NA` in the matched cells, FALSE to exclude `NA` values.

`emptyCells`

A word that specifies how empty cells are matched - must be one of "include" (default), "exclude" or "only".

`outlineCells`

A word that specifies how outline cells are matched - must be one of "include", "exclude" (default) or "only".

`rowNumbers`

A vector of row numbers that specify the rows or cells to constrain the search.

`columnNumbers`

A vector of column numbers that specify the columns or cells to constrain the search.

`cellCoordinates`

A list of two-element vectors that specify the coordinates of cells to constrain the search.

`groups`

A `PivotDataGroup` object or a list of `PivotDataGroup` objects on either the rows or columns axes. The cells to be searched must be related to at least one of these groups.

`rowGroups`

A `PivotDataGroup` object or a list of `PivotDataGroup` objects on the rows axis. The cells to be searched must be related to at least one of these row groups. If both `rowGroups` and `columnGroups` are specified, then the cells to be searched must be related to at least one of the specified row groups and one of the specified column groups.

`columnGroups`

A `PivotDataGroup` object or a list of `PivotDataGroup` objects on the columns axis. The cells to be searched must be related to at least one of these column groups. If both `rowGroups` and `columnGroups` are specified, then the cells to be searched must be related to at least one of the specified row groups and one of the specified column groups.

`rowColumnMatchMode`

Either "simple" (default) or "combinations":

"simple" specifies that row and column arguments are considered separately (logical OR), e.g. rowNumbers=1 and columnNumbers=2 will match all cells in row 1 and all cells in column 2.

"combinations" specifies that row and column arguments are considered together (logical AND), e.g. rowNumbers=1 and columnNumbers=2 will match only the cell single at location (1, 2).

Arguments `rowNumbers`, `columnNumbers`, `rowGroups` and `columnGroups` are affected by the match mode. All other arguments are not.`cells`

A `PivotCell` object or a list of `PivotCell` objects to constrain the scope of the search.

`lowN`

Find the first N cells (ascending order, lowest values first).

`highN`

Find the last N cells (descending order, highest values first).

`findGroupColumnNumbers()`

Find the column numbers associated with a specific data group or groups.

`group`

A `PivotDataGroup` in the column data groups (i.e. a column heading) or a list of column data groups..

`collapse`

A logical value specifying whether the return value should be simplified. See details.

`findGroupRowNumbers()`

Find the row numbers associated with a specific data group or groups.

`group`

A `PivotDataGroup` in the row data groups (i.e. a row heading) or a list of row data groups.

`collapse`

A logical value specifying whether the return value should be simplified. See details.

`removeColumn()`

Remove a column from the pivot table.

`removeColumns()`

Remove multiple column from the pivot table.

`removeRow()`

Remove a row from the pivot table.

`removeRows()`

Remove multiple rows from the pivot table.

`asMatrix()`

Get a matrix containing all of the values from the body of the pivot table.

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