[R] Get median of each column

jim holtman jholtman at gmail.com
Wed Jan 28 20:38:15 CET 2009


?apply

> x <- matrix(1:25,5)
> x
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    6   11   16   21
[2,]    2    7   12   17   22
[3,]    3    8   13   18   23
[4,]    4    9   14   19   24
[5,]    5   10   15   20   25
> apply(x, 2, median)
[1]  3  8 13 18 23
>


On Wed, Jan 28, 2009 at 11:48 AM, Frank Zhang <frankyuzhang at yahoo.com> wrote:
> I am new to R. How can I get column median? Thanks.Frank
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list