tbl_wide_summary {gtsummary} | R Documentation |
Wide summary table
Description
This function is similar to tbl_summary()
, but places summary statistics
wide, in separate columns.
All included variables must be of the same summary type, e.g. all continuous
summaries or all categorical summaries (which encompasses dichotomous variables).
Usage
tbl_wide_summary(
data,
label = NULL,
statistic = switch(type[[1]], continuous = c("{median}", "{p25}, {p75}"), c("{n}",
"{p}%")),
digits = NULL,
type = NULL,
value = NULL,
sort = all_categorical(FALSE) ~ "alphanumeric",
include = everything()
)
Arguments
data |
(data.frame ) A data frame.
|
label |
(formula-list-selector )
Used to override default labels in summary table, e.g. list(age = "Age, years") .
The default for each variable is the column label attribute, attr(., 'label') .
If no label has been set, the column name is used.
|
statistic |
(character )
character vector of the statistics to present. Each element of the vector
will result in a column in the summary table. Default is
c("{median}", "{p25}, {p75}") for continuous summaries, and
c("{n}", "{p}%") for categorical/dichotomous summaries
|
digits |
(formula-list-selector )
Specifies how summary statistics are rounded. Values may be either integer(s)
or function(s). If not specified, default formatting is assigned
via assign_summary_digits() . See below for details.
|
type |
(formula-list-selector )
Specifies the summary type. Accepted value are
c("continuous", "continuous2", "categorical", "dichotomous") .
If not specified, default type is assigned via
assign_summary_type() . See below for details.
|
value |
(formula-list-selector )
Specifies the level of a variable to display on a single row.
The gtsummary type selectors, e.g. all_dichotomous() , cannot be used
with this argument. Default is NULL . See below for details.
|
sort |
(formula-list-selector )
Specifies sorting to perform for categorical variables.
Values must be one of c("alphanumeric", "frequency") .
Default is all_categorical(FALSE) ~ "alphanumeric" .
|
include |
(tidy-select )
Variables to include in the summary table. Default is everything() .
|
Value
a gtsummary table of class 'tbl_wide_summary'
Examples
trial |>
tbl_wide_summary(include = c(response, grade))
trial |>
tbl_strata(
strata = trt,
~tbl_wide_summary(.x, include = c(age, marker))
)
[Package
gtsummary version 2.0.0
Index]