Learn R Programming

table1 (version 1.4.2)

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

Description

Parse abbreviated code for rendering table output.

Usage

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

Value

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

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.

Examples

Run this code
if (FALSE) {
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)
}

Run the code above in your browser using DataLab