Learn R Programming

table1 (version 1.4.2)

render.default: Render values for table output.

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

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,
  ...
)

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.

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab