render.default: Render values for table output.

Description Usage Arguments Value Examples

View source: R/table1.R

Description

Called from table1 by default to render values for displaying in the table. This function forwards the call to separate functions for rendering continuous, categorical and missing values. The idea is that each of these functions can be overridden to customize the table output.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
render.default(
  x,
  name,
  missing = any(is.na(x)),
  transpose = F,
  render.empty = "NA",
  render.continuous = render.continuous.default,
  render.categorical = render.categorical.default,
  render.missing = render.missing.default,
  ...
)

Arguments

x

A vector or numeric, factor, character or logical values.

name

Name of the variable to be rendered (ignored).

missing

Should missing values be included?

transpose

Logical indicating whether on not the table is transposed.

render.empty

A character to return when x is empty.

render.continuous

A function to render continuous (i.e. numeric) values. Can also be a character string, in which case it is passed to parse.abbrev.render.code.

render.categorical

A function to render categorical (i.e. factor, character or logical) values. Can also be a character string, in which case it is passed to parse.abbrev.render.code.

render.missing

A function to render missing (i.e. NA) values. Can also be a character string, in which case it is passed to parse.abbrev.render.code. Set to NULL to ignore missing values.

...

Further arguments, passed to stats.apply.rounding.

Value

A character vector. Each element is to be displayed in a separate cell in the table. The names of the vector are the labels to use in the table. However, the first names should be empty as it will be replaced by the name of the variable. Empty strings are allowed and result in empty table cells.

Examples

1
2
3
4
5
6
7
x <- exp(rnorm(100, 1, 1))
render.default(x)
render.default(x, TRUE)

y <- factor(sample(0:1, 99, replace=TRUE), labels=c("Female", "Male"))
y[1:10] <- NA
render.default(y)

table1 documentation built on June 7, 2021, 1:07 a.m.