PivotCells | R Documentation |
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.
new()
Create a new 'PivotCells' object.
PivotCells$new(parentPivot = NULL)
parentPivot
The pivot table that this 'PivotCells' instance belongs to.
A new 'PivotCells' object.
reset()
Remove all cells from the pivot table and reset row and column counts back to zero.
PivotCells$reset()
No return value.
getColumnGroup()
Get the leaf-level data group that is associated with a specific column or columns in the pivot table.
PivotCells$getColumnGroup(c = NULL)
c
The column number or numbers. The first column is column 1, excluding the column(s) associated with row-headings.
A 'PivotDataGroup' that is associated with the specified column.
getRowGroup()
Get the leaf-level data group that is associated with a specific row or rows in the pivot table.
PivotCells$getRowGroup(r = NULL)
r
The row number or numbers. The first row is row 1, excluding the row(s) associated with column-headings.
A 'PivotDataGroup' that is associated with the specified row
setGroups()
An internal method used when building the cell structure of the pivot table.
PivotCells$setGroups(rowGroups = NULL, columnGroups = NULL)
rowGroups
A list of 'PivotDataGroup' objects to be set as the leaf-level row groups in the pivot table.
columnGroups
A list of 'PivotDataGroup' objects to be set as the leaf-level column groups in the pivot table.
No return value.
getCell()
Get the cell at the specified row and column coordinates in the pivot table.
PivotCells$getCell(r = NULL, c = NULL)
r
Row number of the cell to retrieve.
c
Column number of the cell to retrieve.
The row and column numbers refer only to the cells in the body of the pivot table, i.e. row and column headings are excluded, e.g. row 1 is the first row of cells underneath the column headings.
A 'PivotCell' object representing the cell.
setCell()
Set the cell at the specified row and column coordinates in the pivot table.
PivotCells$setCell(r, c, cell)
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.
This method is intended for internal package use only, used when building # the cell structure. The row and column numbers refer only to the cells in the body of the pivot table, i.e. row and column headings are excluded, e.g. row 1 is the first row of cells underneath the column headings.
No return value.
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'.
A list of 'PivotCell' objects.
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).
A list of 'PivotCell' objects.
findGroupColumnNumbers()
Find the column numbers associated with a specific data group or groups.
PivotCells$findGroupColumnNumbers(group = NULL, collapse = FALSE)
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.
If 'group' is a list: If 'collapse' is 'FALSE', then a list of vectors is returned, if 'collapse' is 'TRUE', then a single combined vector is returned.
Either a vector of column numbers related to the single specified group or a list of vectors containing column numbers related to the specified groups.
findGroupRowNumbers()
Find the row numbers associated with a specific data group or groups.
PivotCells$findGroupRowNumbers(group = NULL, collapse = FALSE)
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.
If 'group' is a list: If 'collapse' is 'FALSE', then a list of vectors is returned, if 'collapse' is 'TRUE', then a single combined vector is returned.
Either a vector of row numbers related to the single specified group or a list of vectors containing row numbers related to the specified groups.
getColumnWidths()
Retrieve the width (in characters) of the longest value in each column.
PivotCells$getColumnWidths()
A vector containing the length of the longest value in each column.
removeColumn()
Remove a column from the pivot table.
PivotCells$removeColumn(c = NULL, renumberGroups = TRUE)
c
The column number. The first column is column 1, excluding the column(s) associated with row-headings.
renumberGroups
'TRUE' (default) to renumber the 'rowColumnNumber' property of the data groups after removing the row.
This method removes both the related column group and cells.
No return value.
removeColumns()
Remove multiple column from the pivot table.
PivotCells$removeColumns(columnNumbers = NULL, renumberGroups = TRUE)
columnNumbers
The column numbers. The first column is column 1, excluding the column(s) associated with row-headings.
renumberGroups
'TRUE' (default) to renumber the 'rowColumnNumber' property of the data groups after removing the row.
This method removes both the related column groups and cells.
No return value.
removeRow()
Remove a row from the pivot table.
PivotCells$removeRow(r = NULL, renumberGroups = TRUE)
r
The row number. The first row is row 1, excluding the row(s) associated with column-headings.
renumberGroups
'TRUE' (default) to renumber the 'rowColumnNumber' property of the data groups after removing the row.
This method removes both the related row group and cells.
No return value.
removeRows()
Remove multiple rows from the pivot table.
PivotCells$removeRows(rowNumbers = NULL, renumberGroups = TRUE)
rowNumbers
The row numbers. The first row is row 1, excluding the rows(s) associated with column-headings.
renumberGroups
'TRUE' (default) to renumber the 'rowColumnNumber' property of the data groups after removing the row.
This method removes both the related row groups and cells.
No return value.
asMatrix()
Get a matrix containing all of the values from the body of the pivot table.
PivotCells$asMatrix(rawValue = TRUE)
rawValue
'TRUE' (default) to populate the matrix with the numerical raw values, 'FALSE' to populate the matrix with the character formatted values.
A 'matrix' containing the values from the body of the pivot table.
asList()
Return the contents of this object as a list for debugging.
PivotCells$asList()
A list of various object properties.
asJSON()
Return the contents of this object as JSON for debugging.
PivotCells$asJSON()
A JSON representation of various object properties.
clone()
The objects of this class are cloneable with this method.
PivotCells$clone(deep = FALSE)
deep
Whether to make a deep clone.
# This class should only be created by the pivot table.
# It is not intended to be created outside of the pivot table.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.