[R] help with median for each row

Jim Lemon jim at bitwrit.com.au
Sat Aug 22 11:54:06 CEST 2009

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? 
Hi Edward,
You can get the default row medians by transposing the matrix and 
sending it to the "describe" function in the prettyR package:


For choosing different methods of calculating the median, you can write 
a wrapper for the "quantile" function:


where "n" is the type of median calculation you want (see the help for 


More information about the R-help mailing list