med: Calculating the Median

Description Usage Arguments Value Examples

Description

Calculates the median of a set of numbers. The function sorts the numbers in the vector and selects the middle number (if the number of entries is odd) or takes the average of the two middle numbers (if the number of entries is even).

Usage

1
med(input, na.rm = FALSE)

Arguments

input

a vector of numbers

na.rm

true or false for whether to remove NA's before performing the calculation

Value

A number

Examples

1
2
3
4
5
a <- c(5,9,4,1,11)
med(a)

b <- c(5,9,4,1,11,2)
med(b)

Andy-McCarthy/BasicMath documentation built on May 27, 2019, 7:24 a.m.