Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

colMedians

Medians of Columns


Description

Compute the sample medians of the columns (non-rows) of a data.frame or array.

Usage

colMedians( x, na.rm = FALSE )

Arguments

x

a data.frame or array.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

Value

A vector or array of the medians of each column (non-row) of x with dimension dim( x )[-1].

Author(s)

Arne Henningsen

See Also

Examples

data( "Electricity", package = "Ecdat" )
   colMedians( Electricity )

   a4 <- array( 1:120, dim = c(5,4,3,2),
      dimnames = list( c("a","b","c","d","e"), c("A","B","C","D"),
      c("x","y","z"), c("Y","Z") ) )
   colMedians( a4 )
   median( a4[ , "B", "x", "Z" ] )  # equal to
   colMedians( a4 )[ "B", "x", "Z" ]

miscTools

Miscellaneous Tools and Utilities

v0.6-26
GPL (>= 2)
Authors
Arne Henningsen, Ott Toomet
Initial release
2019-12-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.