rep_median_ci {kdry}R Documentation

rep_median_ci

Description

Reporting helper function: computes and formats median and confidence interval from a numeric vector.

Usage

rep_median_ci(
  x,
  conf_int,
  digits = 2,
  na.rm = TRUE,
  collapse = "to",
  iqr_brackets = c("round", "square"),
  iqr_prefix = TRUE,
  weighted = FALSE,
  weights = NA
)

Arguments

x

A numeric vector.

conf_int

A numeric between 0 and 100 to indicate the confidence interval that should be computed.

digits

An integer indicating the number of decimal places.

na.rm

A logical indicating if missings should be removed from x before computing the distributional parameters (default: TRUE).

collapse

A character which is placed between the lower and the upper confidence bound in the formatted output.

iqr_brackets

A character. Either "round" (default) or "square" to indicate the type of brackets to surround the confidence interval in the formatted output.

iqr_prefix

A logical. If TRUE (default), the confidence interval is prefixed with "IQR: ".

weighted

A logical. If TRUE, a weighted median and confidence interval are calculated (default: FALSE).

weights

A numeric vector of weights passed further on to Hmisc::wtd.quantile() if weighted = TRUE (default: NA).

Value

A character with the formatted output.

See Also

stats::median, stats::quantile, Hmisc::wtd.quantile()

Examples

set.seed(123)
x <- rnorm(1000)
rep_median_ci(x, conf_int = 95)
rep_median_ci(rep(1, 10), conf_int = 95)
rep_median_ci(x, conf_int = 95, collapse = "-")
rep_median_ci(x, iqr_brackets = "square", conf_int = 50)


[Package kdry version 0.0.2 Index]