medf: Format median

View source: R/stats.R

medfR Documentation

Format median

Description

The purpose of this function is to calculate the median, 25th and 75th percentiles of a numeric vector and format output as a string.

Usage

medf(x, digits = 2, na.rm = TRUE, ...)

Arguments

x

Numeric vector to summarize

digits

The number of decimal places to use; default is 2

na.rm

Boolean indicating whether or not NA and NaN values should be dropped; inherited by fivenum; default is TRUE

...

Additional arguments passed to formatC

Details

Note that the values for median, 25th, and 75th percentiles are calculated using fivenum.

Value

Character vector of length 1 with formatted median followed by 25th,75th percentiles in parentheses:"median (25th,75th)". The formatting can be further customized using arguments to base::formatC.

Examples


x <- sample(1:9, size = 100, replace = TRUE, prob = seq(0.9,0.1,-0.1))
medf(x)


vpnagraj/yawp documentation built on March 31, 2022, 9:56 a.m.