Learn R Programming

rtables (version 0.6.6)

format_rcell: Format rcell

Description

This is a wrapper around 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,
  shell = FALSE
)

Value

formatted text representing the cell

Arguments

x

an object of class CellValue, or a raw value.

format

character(1) or function. The format label (string) or formatter function to apply to x.

output

character(1). Output type.

na_str

character(1). String that should be displayed when the value of x is missing. Defaults to "NA".

pr_row_format

list of default format coming from the general row.

pr_row_na_str

list of default "NA" string coming from the general row.

shell

logical(1). Should the formats themselves be returned instead of the values with formats applied. Defaults to FALSE.

Examples

Run this code
cll <- CellValue(pi, format = "xx.xxx")
format_rcell(cll)

# Cell values precedes the row values
cll <- CellValue(pi, format = "xx.xxx")
format_rcell(cll, pr_row_format = "xx.x")

# 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")

Run the code above in your browser using DataLab