Description Usage Arguments Details Value Examples
There are two interfaces, the default, which typically takes a list of
data.frame
s for x
, and the formula interface. The formula
interface is less flexible, but simpler to use and designed to handle the
most common use cases. It is important to use factors appropriately for
categorical variables (i.e. have the levels labeled properly and in the
desired order). The contents of the table can be customized by providing
user-defined ‘renderer’ functions. To facilitate this, some tags (such as
row labels) are given specific classes for easy CSS selection.
1 2 3 4 5 6 7 8 9 10 11 12 |
vars |
Variables to be used for summary table. |
data |
A |
group |
Name of the grouping variable. |
row_split |
Variable that used for splitting table rows, rows will be splited using this variable. Useful for repeated measures. |
overall |
A label for the "Total" column. Specify |
select |
a named vector with as many components as row-variables. Every element of 'select' will be used to select the individuals to be analyzed for every row-variable. Name of the vector corresponds to the row variable, element is the selection. |
render |
A function to render the table cells (see Details). |
drop_lev |
Should empty factor levels be dropped? |
indent |
Indent symbol of the table for statistic values. |
... |
Further arguments, passed to |
For the default version, is is expected that x
is a named
list of data.frame
s, one for each stratum, with names corresponding to
strata labels.
An object of class "tab1".
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | dat <- expand.grid(id=1:10, sex=c("Male", "Female"), treat=c("Treated", "Placebo"))
dat$age <- runif(nrow(dat), 10, 50)
dat$age[3] <- NA # Add a missing value
dat$wt <- exp(rnorm(nrow(dat), log(70), 0.2))
var_lab(dat$sex) <- "Sex"
var_lab(dat$age) <- "Age"
var_lab(dat$treat) <- "Treatment Group"
var_lab(dat$wt) <- "Weight"
# Something more complicated
dat$dose <- ifelse(dat$treat=="Placebo", "Placebo",
sample(c("5 mg", "10 mg"), nrow(dat), replace=TRUE))
dat$dose <- factor(dat$dose, levels=c("Placebo", "5 mg", "10 mg"))
my.render.cont <- function(x) {
with(stats.default(x),
sprintf("%0.2f (%0.1f)", MEAN, SD))
}
tab1(c("age", "sex", "wt"),
data = dat,
group = "treat",
render.continuous=my.render.cont)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.