[R] ave across columns

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Jan 21 09:25:04 CET 2003


"Petr Pikal" <petr.pikal at precheza.cz> writes:

> On 20 Jan 2003 at 17:46, Hedderik van Rijn wrote:
> 
> > x <- matrix(rnorm(60),20)
> > x[sample(1:60,10)] <- NA
> > apply(x,1,mean,na.rm=T)
> or simply
> 
> colMeans(x,na.rm=T)

rowMeans, you mean.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list