add_summary {tidysummary} | R Documentation |
Add summary statistics to a add_var object
Description
This function generates summary statistics for variables from a data frame that has been processed by add_var()
, with options to format outputs.
Usage
add_summary(
data,
add_overall = TRUE,
continuous_format = NULL,
norm_continuous_format = "{mean} ± {SD}",
unnorm_continuous_format = "{median} ({Q1}, {Q3})",
categorical_format = "{n} ({pct})",
binary_show = "last",
digit = 2
)
Arguments
data |
A data frame that has been processed by |
add_overall |
Logical indicating whether to include an "Overall" summary column. |
continuous_format |
Format string to override both normal/abnormal continuous formats. Accepted placeholders are |
norm_continuous_format |
Format string for normally distributed continuous variables. Default is |
unnorm_continuous_format |
Format string for non-normal continuous variables. Default is |
categorical_format |
Format string for categorical variables. Default is |
binary_show |
Display option for binary variables:
|
digit |
digit A numeric determine decimal. |
Value
A data frame containing summary statistics with the following columns:
-
variable
: Variable name -
Overall (n=X)
: Summary statistics for all data, ifadd_overall=TRUE
Group-specific columns named
[group] (n=X)
with summary statistics
Examples
# `data` is a data frame processed by `add_var()`:
data <- add_var(iris, var = c("Sepal.Length", "Species"), group = "Species")
# Add summary statistics
result <- add_summary(data, add_overall = TRUE)
result <- add_summary(data, continuous_format = "{mean}, ({SD})")