[R] help with median for each row

Matthias Kohl Matthias.Kohl at stamats.de
Fri Aug 21 19:05:56 CEST 2009


if your matrix has many rows you might want to consider rowMedians from 
Bioconductor package Biobase.
hth,
Matthias

Greg Hirson schrieb:
> Edward,
>
> See ?apply
>
> x = matrix(rnorm(100), ncol = 10)
> apply(x, 1, median)
>
> Hope this helps,
>
> Greg
>
> Edward Chen wrote:
>> Hi,
>>
>> I tried looking through google search on whether there's a way to 
>> computer
>> the median for each row of a nxn matrix and return the medians for 
>> each row
>> for further computation.
>> And also if the number of columns in the matrix are even, how could I
>> specify which median to use?
>>
>> Thank you very much!
>>
>>   
>

-- 
Dr. Matthias Kohl
www.stamats.de




More information about the R-help mailing list