This function is similar to tbl_ard_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_ard_wide_summary(
cards,
statistic = switch(type[[1]], continuous = c("{median}", "{p25}, {p75}"), c("{n}",
"{p}%")),
type = NULL,
label = NULL,
value = NULL,
include = everything()
)
Arguments
- cards
(
card
)
An ARD object of class"card"
typically created withcards::ard_*()
functions.- statistic
(
character
)
character vector of the statistics to present. Each element of the vector will result in a column in the summary table. Default isc("{median}", "{p25}, {p75}")
for continuous summaries, andc("{n}", "{p}%")
for categorical/dichotomous summaries- type
(
formula-list-selector
)
Specifies the summary type. Accepted value arec("continuous", "continuous2", "categorical", "dichotomous")
. If not specified, default type is assigned viaassign_summary_type()
. See below for details.- 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.- 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 isNULL
. See below for details.- include
(
tidy-select
)
Variables to include in the summary table. Default iseverything()
.
Examples
library(cards)
ard_stack(
trial,
ard_continuous(variables = age),
.missing = TRUE,
.attributes = TRUE,
.total_n = TRUE
) |>
tbl_ard_wide_summary()
Characteristic
Median
Q1, Q3
ard_stack(
trial,
ard_dichotomous(variables = response),
ard_categorical(variables = grade),
.missing = TRUE,
.attributes = TRUE,
.total_n = TRUE
) |>
tbl_ard_wide_summary()
Characteristic
n
%