powered by
Reporting helper function: computes and formats mean and standard deviation from a numeric vector.
rep_mean_sd( x, digits = 2, na.rm = TRUE, sd_brackets = c("round", "square"), sd_prefix = TRUE, weighted = FALSE, weights = NA )
A character with the formatted output.
A numeric vector.
An integer indicating the number of decimal places.
A logical indicating if missings should be removed from x before computing the distributional parameters (default: TRUE).
x
TRUE
A character. Either "round" (default) or "square" to indicate the type of brackets to surround the standard deviation in the formatted output.
"round"
"square"
A logical. If TRUE (default), the standard deviation is prefixed with a plus-minus-sign ("±").
A logical. If TRUE, a weighted mean and standard deviation are calculated (default: FALSE).
FALSE
A vector with the weights (if weighted = TRUE; default: NA) passed futher on to stats::weighted.mean() and Hmisc::wtd.var().
weighted = TRUE
NA
stats::weighted.mean()
Hmisc::wtd.var()
mean(), stats::sd(), stats::weighted.mean(), Hmisc::wtd.var()
mean()
stats::sd()
set.seed(123) x <- rnorm(1000) rep_mean_sd(x) rep_mean_sd(rep(1, 10)) rep_mean_sd(x, sd_brackets = "square") rep_mean_sd(x, sd_brackets = "square", sd_prefix = FALSE)
Run the code above in your browser using DataLab