meansd: Compute mean and sd and put together with the ± symbol.

View source: R/descriptives.R

meansdR Documentation

Compute mean and sd and put together with the ± symbol.

Description

Compute mean and sd and put together with the ± symbol.

Usage

meansd(
  x,
  roundDig = 2,
  drop0 = FALSE,
  groupvar = NULL,
  range = FALSE,
  rangesep = " ",
  add_n = FALSE,
  .german = FALSE,
  ci = FALSE,
  nrepl = 10^3,
  singleline = TRUE
)

Arguments

x

Data for computation.

roundDig

Number of relevant digits for roundR.

drop0

Should trailing zeros be dropped?

groupvar

Optional grouping variable for subgroups.

range

Should min and max be included in output?

rangesep

How should min/max be separated from mean+-sd?

add_n

Should n be included in output?

.german

Logical, should "." and "," be used as bigmark and decimal?

ci

Should bootstrap based 95% confidence interval be computed?

nrepl

Number of bootstrap replications, defaults to 1000.

singleline

Put all descriptive stats in a single element (default) or below each other. singleline = FALSE sets ci and add_n as TRUE

Value

Either character vector with mean ± SD and additional results (singleline), or matrix with rows for n, mean with CI, and SD, and optionally range.

Examples

# basic usage of meansd
meansd(x = mtcars$wt)
# with additional options
meansd(x = mtcars$wt, groupvar = mtcars$am, add_n = TRUE)
meansd(x = mtcars$wt, groupvar = mtcars$am, add_n = TRUE, ci = TRUE, singleline = FALSE)

abusjahn/wrappedtools documentation built on June 10, 2025, 10:52 a.m.