parse.abbrev.render.code: Parse abbreviated code for rendering table output.

View source: R/table1.R

parse.abbrev.render.codeR Documentation

Parse abbreviated code for rendering table output.

Description

Parse abbreviated code for rendering table output.

Usage

parse.abbrev.render.code(code, ...)

Arguments

code

A character vector specifying the statistics to display in abbreviated code. See Details.

...

Further arguments, passed to stats.apply.rounding.

Details

In abbreviated code, the words N, NMISS, MEAN, SD, MIN, MEDIAN, MAX, IQR, CV, GMEAN, GSD, GCV, FREQ and PCT are substituted for their respective values (see stats.default). The substitution is case insensitive, and the substituted values are rounded appropriately (see stats.apply.rounding). Other text is left unchanged. The code can be a vector, in which case each element is displayed in its own row in the table. The names of code are used as row labels; if no names are present, then the code itself is used unless code is of length 1, in which case no label is used (for numeric variables only, categorical variables are always labeled by the class label). The special name '.' also indicates that code itself be is used as the row label.

Value

A function that takes a single argument and returns a character vector.

Examples

## Not run: 
x <- round(exp(rnorm(100, log(20), 1)), 2)
stats.default(x)
f <- parse.abbrev.render.code(c("Mean (SD)", "Median [Min, Max]"), 3)
f(x)
f2 <- parse.abbrev.render.code(c("Geo. Mean (Geo. CV%)" = "GMean (GCV%)"), 3)
f2(x)
f3 <- parse.abbrev.render.code(c("Mean (SD)"), 3)
f3(x)

x <- sample(c("Male", "Female"), 30, replace=T)
stats.default(x)
f <- parse.abbrev.render.code("Freq (Pct%)")
f(x)

## End(Not run)


table1 documentation built on Jan. 6, 2023, 5:07 p.m.