Median

DESCRIPTION:
Returns a number which is the median of the data. Missing values can be removed before the computation.

USAGE:
median(x, na.rm = F)

REQUIRED ARGUMENTS:
x:
numeric object.
Missing values (NA) are allowed.

OPTIONAL ARGUMENTS:
na.rm:
logical flag: should missing values be removed before computation?

VALUE:
median of the data.

DETAILS:
If x contains any NAs, the result will be NA unless na.rm=TRUE.

NOTE:
For long vectors using quantile(x, .5) rather than median(x) will be significantly faster since quantile uses a partial sort while median uses a sort. However, quantile uses single precision.

SEE ALSO:
apply , mad , mean , quantile , robloc , testscores .

EXAMPLES:
algebra <- testscores[,3] # create sample object of algebra testscores
median(algebra) # median of scores

apply(testscores, 2, median) # vector of the medians of the columns # in testscores data set