mean_sd: Mean and Standard deviation

Description Usage Arguments Details Value Examples

View source: R/mean_sd.R

Description

A function for calculating and formatting means and standard deviations.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
mean_sd(
  x,
  digits = getOption("qwraps2_frmt_digits", 2),
  na_rm = FALSE,
  show_n = "ifNA",
  denote_sd = "pm",
  markup = getOption("qwraps2_markup", "latex")
)

gmean_sd(
  x,
  digits = getOption("qwraps2_frmt_digits", 2),
  na_rm = FALSE,
  show_n = "ifNA",
  denote_sd = "pm",
  markup = getOption("qwraps2_markup", "latex")
)

Arguments

x

a numeric vector

digits

digits to the right of the decimal point to return in the percentage estimate.

na_rm

if true, omit NA values

show_n

defaults to "ifNA". Other options are "always" or "never".

denote_sd

a character string set to either "pm" or "paren" for reporting 'mean \pm sd' or 'mean (sd)'

markup

latex or markdown

Details

Given a numeric vector, mean_sd will return a character string with the mean and standard deviation. Formatting of the output will be extended in future versions.

gmean_sd returns the geometric mean and geometric standard deviation.

Value

a character vector of the formatted values

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set.seed(42)
x <- rnorm(1000, 3, 4)
mean(x)
sd(x)
mean_sd(x)
mean_sd(x, show_n = "always")
mean_sd(x, show_n = "always", denote_sd = "paren")

x[187] <- NA
mean_sd(x, na_rm = TRUE)

qwraps2 documentation built on March 7, 2021, 5:06 p.m.