This is a wrapper for formatters::format_value() for use with CellValue objects
Usage
format_rcell(
x,
format,
output = c("ascii", "html"),
na_str = obj_na_str(x) %||% "NA",
pr_row_format = NULL,
pr_row_na_str = NULL,
round_type = c("iec", "sas"),
shell = FALSE
)Arguments
- x
(
CellValueorANY)
an object of classCellValue, or a raw value.- format
(
stringorfunction)
the format label or formatter function to apply tox.- output
(
string)
output type.- na_str
(
string)
string that should be displayed when the value ofxis missing. Defaults to"NA".- pr_row_format
(
list)
list of default formats coming from the general row.- pr_row_na_str
(
list)
list of default"NA"strings coming from the general row.- round_type
(
"iec"or"sas")
the type of rounding to perform. iec, the default, peforms rounding compliant with IEC 60559 (see details), while sas performs nearest-value rounding consistent with rounding within SAS.- shell
(
flag)
whether the formats themselves should be returned instead of the values with formats applied. Defaults toFALSE.
Examples
cll <- CellValue(pi, format = "xx.xxx")
format_rcell(cll)
#> [1] "3.142"
# Cell values precedes the row values
cll <- CellValue(pi, format = "xx.xxx")
format_rcell(cll, pr_row_format = "xx.x")
#> [1] "3.142"
# Similarly for NA values
cll <- CellValue(NA, format = "xx.xxx", format_na_str = "This is THE NA")
format_rcell(cll, pr_row_na_str = "This is NA")
#> [1] "This is THE NA"