median {stats}R Documentation

Median Value

Description

Compute the sample median.

Usage

median(x, na.rm = FALSE)

Arguments

x an object for which a method has been defined, or a numeric vector containing the values whose median is to be computed.
na.rm a logical value indicating whether NA values should be stripped before the computation proceeds.

Details

This is a generic function for which methods can be written. However, the default method makes use of sort and mean, both of which are generic, and so the default method will work for most classes (e.g. "Date") for which a median is a reasonable concept.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

See Also

quantile for general quantiles.

Examples

median(1:4)# = 2.5 [even number]
median(c(1:3,100,1000))# = 3 [odd, robust]

[Package stats version 2.5.0 Index]