frmt {tfrmt}R Documentation

Table Value Formatting

Description

These functions provide an abstracted way to approach to define formatting of table contents. By defining in this way, the formats can be layered to be more specific and general cell styling can be done first.

frmt() is the base definition of a format. This defines spacing, rounding, and missing behaviour.

frmt_combine() is used when two or more rows need to be combined into a single cell in the table. Each of the rows needs to have a defined frmt() and need to share a label.

frmt_when() is used when a rows format behaviour is dependent on the value itself and is written similarly to dplyr::case_when(). The left hand side of the equation is a "TRUE"for the default case or the right hand side of a boolean expression ">50".

Usage

frmt(expression, missing = NULL, scientific = NULL, transform = NULL, ...)

frmt_combine(expression, ..., missing = NULL)

frmt_when(..., missing = NULL)

Arguments

expression

this is the string representing the intended format. See details: expression for more a detailed description.

missing

when a value is missing that is intended to be formatted, what value to place. See details: missing for more a detailed description.

scientific

a string representing the intended scientific notation to be appended to the expression. Ex. "e^XX" or " x10^XX".

transform

this is what should happen to the value prior to formatting, It should be a formula or function. Ex. ~.*100if you want to convert a percent from a decimal prior to rounding

...

See details: ... for a detailed description.

Details

expression

missing

...

Value

frmt object

See Also

body_plan() combines the frmt_structures to be applied to the table body, and frmt_structure() defines which rows the formats will be applied to.

Link to related article

Examples


frmt("XXX %")

frmt("XX.XXX")

frmt("xx.xx", scientific = "x10^xx")

frmt_combine(
 "{param1} {param2}",
 param1 = frmt("XXX %"),
 param2 = frmt("XX.XXX")
)

frmt_when(
  ">3" ~ frmt("(X.X%)"),
  "<=3" ~ frmt("Undetectable")
  )

frmt_when(
  "==100"~ frmt(""),
  "==0"~ "",
  "TRUE" ~ frmt("(XXX.X%)")
  )


[Package tfrmt version 0.1.2 Index]