Compute the sample median.
median(x, na.rm = FALSE, ...)
an object for which a method has been defined, or a numeric vector containing the values whose median is to be computed.
a logical value indicating whether
potentially further arguments for methods; not used in the default method.
This is a generic function for which methods can be written. However,
the default method makes use of
mean from package base all of which are generic, and so
the default method will work for most classes
"Date") for which a median is a reasonable
The default method returns a length-one object of the same type as
x, except when
x is logical or integer of even length,
when the result will be double.
If there are no values or if
na.rm = FALSE and there are
values the result is
NA of the same type as
x (or more
generally the result of
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
quantile for general quantiles.
median(1:4) # = 2.5 [even number] median(c(1:3, 100, 1000)) # = 3 [odd, robust]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.