median_iqr: Median and Inner Quartile Range

View source: R/median_iqr.R

median_iqrR Documentation

Median and Inner Quartile Range

Description

A function for calculating and formatting the median and inner quartile range of a data vector.

Usage

median_iqr(
  x,
  digits = getOption("qwraps2_frmt_digits", 2),
  na_rm = FALSE,
  show_n = "ifNA",
  markup = getOption("qwraps2_markup", "latex"),
  ...
)

Arguments

x

a numeric vector

digits

digits to the right of the decimal point to return.

na_rm

if true, omit NA values

show_n

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

markup

latex or markdown

...

pass through

Details

Given a numeric vector, median_iqr will return a character string with the median and IQR. Formatting of the output will be extended in future versions.

Value

a character vector of the formatted values

Examples

set.seed(42)
x <- rnorm(1000, 3, 4)
median(x)
quantile(x, probs = c(1, 3)/4)
median_iqr(x)
median_iqr(x, show_n = "always")

x[187] <- NA
# median_iqr(x) ## Will error
median_iqr(x, na_rm = TRUE)


dewittpe/qwraps2 documentation built on Jan. 4, 2024, 1:59 p.m.