The `TableCells` manages the `TableCell` objects that comprise a `BasicTable` object.
R6Class object.
rowCountThe number of rows in the table.
columnCountThe number of columns in the table.
rowsThe rows of cells in the table - represented as a list, each element of which is a list of `TableCell` objects.
allA list of the cells in the table. Each element in this list is a `TableCell` object.
new()Create a new `TableCells` object.
TableCells$new(parentTable = NULL)
parentTableOwning table.
No return value.
reset()Clear all cells from the table.
TableCells$reset()
No return value.
getCell()Retrieve a specific `TableCell` object at the specified location in the table.
TableCells$getCell(r = NULL, c = NULL)
rThe row number of the cell to retrieve.
cThe column number of the cell to retrieve.
A `TableCell` object.
getValue()Retrieve the value of a specific `TableCell` object at the specified location in the table.
TableCells$getValue(r = NULL, c = NULL, formattedValue = FALSE)
rThe row number of the cell value to retrieve.
cThe column number of the cell value to retrieve.
formattedValue`TRUE` to retrieve the formatted (character) cell value, `FALSE` (default) to retrieve the raw cell value (typically numeric).
The value of the cell.
getRowValues()Get a vector or list of the values in a row for the entire row or a subset of columns.
TableCells$getRowValues( rowNumber = NULL, columnNumbers = NULL, formattedValue = FALSE, asList = FALSE, rebase = TRUE )
rowNumberThe row number to retrieve the values for (a single row number).
columnNumbersThe column numbers of the cell value to retrieve (can be a vector of column numbers).
formattedValue`TRUE` to retrieve the formatted (character) cell value, `FALSE` (default) to retrieve the raw cell value (typically numeric).
asList`TRUE` to retrieve the values as a list, `FALSE` (default) to retrieve the values as a vector.
rebase`TRUE` to rebase the list/vector so that the first element is at index 1, `FALSE` to retain the original column numbers.
A vector or list of the cell values.
getColumnValues()Get a vector or list of the values in a column for the entire column or a subset of rows.
TableCells$getColumnValues( columnNumber = NULL, rowNumbers = NULL, formattedValue = FALSE, asList = FALSE, rebase = TRUE )
columnNumberThe column number to retrieve the values for (a single column number).
rowNumbersThe row numbers of the cell value to retrieve (can be a vector of row numbers).
formattedValue`TRUE` to retrieve the formatted (character) cell value, `FALSE` (default) to retrieve the raw cell value (typically numeric).
asList`TRUE` to retrieve the values as a list, `FALSE` (default) to retrieve the values as a vector.
rebase`TRUE` to rebase the list/vector so that the first element is at index 1, `FALSE` to retain the original row numbers.
A vector or list of the cell values.
setCell()Create a cell in the table and set the details of the cell.
TableCells$setCell( r = NULL, c = NULL, cellType = "cell", rawValue = NULL, formattedValue = NULL, visible = TRUE, baseStyleName = NULL, styleDeclarations = NULL, rowSpan = NULL, colSpan = NULL )
rThe row number of the cell.
cThe column number of the cell.
cellTypeThe type of the cell - must be one of the following values: root, rowHeader, columnHeader, cell, total.
rawValueThe raw value of the cell - typically a numeric value.
formattedValueThe formatted value of the cell - typically a character value.
visible`TRUE` (default) to specify that the cell is visible, `FALSE` to specify that the cell will be invisible.
baseStyleNameThe name of a style from the table theme that will be used to style this cell.
styleDeclarationsA list of CSS style definitions.
rowSpanA number greater than 1 to indicate that this cell is merged with cells below. `NULL` (default) or 1 means the cell is not merged across rows.
colSpanA number greater than 1 to indicate that this cell is merged with cells to the right. `NULL` (default) or 1 means the cell is not merged across columns.
A vector or list of the cell values.
setBlankCell()Create an empty cell in the table and set the details of the cell.
TableCells$setBlankCell( r = NULL, c = NULL, cellType = "cell", visible = TRUE, baseStyleName = NULL, styleDeclarations = NULL, rowSpan = NULL, colSpan = NULL, asNBSP = FALSE )
rThe row number of the cell.
cThe column number of the cell.
cellTypeThe type of the cell - must be one of the following values: root, rowHeader, columnHeader, cell, total.
visible`TRUE` (default) to specify that the cell is visible, `FALSE` to specify that the cell will be invisible.
baseStyleNameThe name of a style from the table theme that will be used to style this cell.
styleDeclarationsA list of CSS style definitions.
rowSpanA number greater than 1 to indicate that this cell is merged with cells below. `NULL` (default) or 1 means the cell is not merged across rows.
colSpanA number greater than 1 to indicate that this cell is merged with cells to the right. `NULL` (default) or 1 means the cell is not merged across columns.
asNBSP`TRUE` if the cell should be rendered as in HTML, `FALSE` (default) otherwise.
A vector or list of the cell values.
deleteCell()Replace the `TableCell` object at the specified location in the table with a blank cell.
TableCells$deleteCell(r = NULL, c = NULL)
rThe row number of the cell value to delete
cThe column number of the cell value to delete
The `TableCell` object that is the new blank cell.
setValue()Update the value of a cell in the table.
TableCells$setValue(r = NULL, c = NULL, rawValue = NULL, formattedValue = NULL)
rThe row number of the cell.
cThe column number of the cell.
rawValueThe raw value of the cell - typically a numeric value.
formattedValueThe formatted value of the cell - typically a character value.
No return value.
setRow()Create multiple cells in one row of a table.
TableCells$setRow( rowNumber = NULL, startAtColumnNumber = 1, cellTypes = "cell", rawValues = NULL, formattedValues = NULL, formats = NULL, visiblity = TRUE, baseStyleNames = NULL, fmtFuncArgs = NULL )
rowNumberThe row number where the cells will be created.
startAtColumnNumberThe column number to start generating cells at. Default value 1.
cellTypesThe types of the cells - either a single value or a vector of the same length as rawValues. Each cellType must be one of the following values: root, rowHeader, columnHeader, cell, total.
rawValuesA vector or list of values. A cell will be generated in the table for each element in the vector/list.
formattedValuesA vector or list of formatted values. Must be either `NULL`, a single value or a vector/list of the same length as rawValues.
formatsA vector or list of formats. Must be either `NULL`, a single value or a vector/list of the same length as rawValues.
visiblityA logical vector. Must be either a single logical value or a vector/list of the same length as rawValues.
baseStyleNamesA character vector. Must be either a single style name (from the table theme) or a vector of style names of the same length as rawValues.
fmtFuncArgsA list that is length 1 or the same length as the number of columns in the row, where each list element specifies a list of arguments to pass to custom R format functions.
No return value.
setColumn()Create multiple cells in one column of a table.
TableCells$setColumn( columnNumber = NULL, startAtRowNumber = 2, cellTypes = "cell", rawValues = NULL, formattedValues = NULL, formats = NULL, visiblity = TRUE, baseStyleNames = NULL, fmtFuncArgs = NULL )
columnNumberThe column number where the cells will be created.
startAtRowNumberThe row number to start generating cells at. Default value 2.
cellTypesThe types of the cells - either a single value or a vector of the same length as rawValues. Each cellType must be one of the following values: root, rowHeader, columnHeader, cell, total.
rawValuesA vector or list of values. A cell will be generated in the table for each element in the vector/list.
formattedValuesA vector or list of formatted values. Must be either `NULL`, a single value or a vector of the same length as rawValues.
formatsA vector or list of formats. Must be either `NULL`, a single value or a vector of the same length as rawValues.
visiblityA logical vector. Must be either a single logical value or a vector of the same length as rawValues.
baseStyleNamesA character vector. Must be either a single style name (from the table theme) or a vector of style names of the same length as rawValues.
fmtFuncArgsA list that is length 1 or the same length as the number of rows in the column, where each list element specifies a list of arguments to pass to custom R format functions.
No return value.
extendCells()Enlarge a table to the specified size.
TableCells$extendCells(rowCount = NULL, columnCount = NULL)
rowCountThe number of rows in the enlarged table.
columnCountThe number of columns in the enlarged table.
No return value.
moveCell()Move a table cell to a different location in the table.
TableCells$moveCell(r = NULL, c = NULL, cell = NULL)
rThe new row number to move the cell to.
cThe new column number to move the cell to.
cellThe `TableCell` object to move.
No return value.
insertRow()Insert a new row in the table at the specified row number and shift existing cells on/below this row down by one row.
TableCells$insertRow( rowNumber = NULL, insertBlankCells = TRUE, headerCells = 1, totalCells = 0 )
rowNumberThe row number where the new row is to be inserted.
insertBlankCells`TRUE` (default) to insert blank cells in the new row, `FALSE` to create no cells in the new row.
headerCellsThe number of header cells to create at the start of the row. Default value 1.
totalCellsThe number of total cells to create at the end of the row. Default value 0.
No return value.
deleteRow()Delete the row in the table at the specified row number and shift existing cells below this row up by one row.
TableCells$deleteRow(rowNumber = NULL)
rowNumberThe row number of the row to be deleted.
No return value.
insertColumn()Insert a new column in the table at the specified column number and shift existing cells in/to the right of this column across by one row.
TableCells$insertColumn( columnNumber = NULL, insertBlankCells = TRUE, headerCells = 1, totalCells = 0 )
columnNumberThe column number where the new column is to be inserted.
insertBlankCells`TRUE` (default) to insert blank cells in the new column, `FALSE` to create no cells in the new column
headerCellsThe number of header cells to create at the top of the column. Default value 1.
totalCellsThe number of total cells to create at the bottom of the column. Default value 0.
No return value.
deleteColumn()Delete the column in the table at the specified column number and shift existing cells to the right of this column to the left by one column.
TableCells$deleteColumn(columnNumber = NULL)
columnNumberThe column number of the column to be deleted.
No return value.
getCells()Retrieve cells by a combination of row and/or column numbers. See the "Finding and Formatting" vignette for graphical examples.
TableCells$getCells( specifyCellsAsList = TRUE, rowNumbers = NULL, columnNumbers = NULL, cellCoordinates = NULL, excludeEmptyCells = FALSE, matchMode = "simple" )
specifyCellsAsList`TRUE`/`FALSE` to specify how cells are retrieved. Default `TRUE`. More information is provided in the details section.
rowNumbersA vector of row numbers that specify the rows or cells to retrieve.
columnNumbersA vector of row numbers that specify the columns or cells to retrieve.
cellCoordinatesA list of two-element vectors that specify the coordinates of cells to retrieve. Ignored when `specifyCellsAsList=FALSE`.
excludeEmptyCellsDefault `FALSE`. Specify `TRUE` to exclude empty cells.
matchModeEither "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 `TableCell` objects.
findCells()Find cells matching specified criteria. See the "Finding and Formatting" vignette for graphical examples.
TableCells$findCells( minValue = NULL, maxValue = NULL, exactValues = NULL, valueRanges = NULL, includeNull = TRUE, includeNA = TRUE, emptyCells = "include", rowNumbers = NULL, columnNumbers = NULL, cellCoordinates = NULL, cells = NULL, rowColumnMatchMode = "simple" )
minValueA numerical value specifying a minimum value threshold.
maxValueA numerical value specifying a maximum value threshold.
exactValuesA vector or list specifying a set of allowed values.
valueRangesA 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.
includeNullSpecify TRUE to include `NULL` in the matched cells, FALSE to exclude `NULL` values.
includeNASpecify TRUE to include `NA` in the matched cells, FALSE to exclude `NA` values.
emptyCellsA word that specifies how empty cells are matched - must be one of "include" (default), "exclude" or "only".
rowNumbersA vector of row numbers that specify the rows or cells to constrain the search.
columnNumbersA vector of column numbers that specify the columns or cells to constrain the search.
cellCoordinatesA list of two-element vectors that specify the coordinates of cells to constrain the search.
cellsA `TableCell` object or a list of `TableCell` objects to constrain the scope of the search.
rowColumnMatchModeEither "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.
A list of `TableCell` objects.
getColumnWidths()Retrieve the width of the longest value (in characters) in each column.
TableCells$getColumnWidths()
The width of the column in characters.
asList()Return the contents of this object as a list for debugging.
TableCells$asList()
A list of various object properties.
asJSON()Return the contents of this object as JSON for debugging.
TableCells$asJSON()
A JSON representation of various object properties.
clone()The objects of this class are cloneable with this method.
TableCells$clone(deep = FALSE)
deepWhether to make a deep clone.
# This class should only be created by the table. # It is not intended to be created outside of the table. library(basictabler) tbl <- qtbl(data.frame(a=1:2, b=3:4)) cells <- tbl$cells cells$setCell(r=4, c=1, cellType="cell", rawValue=5) cells$setCell(r=4, c=2, cellType="cell", rawValue=6) tbl$renderTable()