Learn R Programming

qwraps2 (version 0.1.2)

median_iqr: 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 (NOT CURRENTLY IMPLEMENTED)
show_n
defaults to "ifNA". Other options are "always" or "never".
markup
latex or markdown

Value

  • a character vector of the formatted values

Details

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

Examples

Run this code
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)

Run the code above in your browser using DataLab