[R] ave across columns

Petr Pikal petr.pikal at precheza.cz
Tue Jan 21 07:59:03 CET 2003


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)

> 
> On Monday, January 20, 2003, at 04:27 PM, Truc Truong wrote:
> 
> > Hi:
> >
> > How do I find average across three columns such as weight1, weight2,
> > weight3 (20 people, each person has three different measures)? They
> > have NA's also.  Thanks
> >
> > Tom, Univ of Pittsburgh, ttrut at yahoo.com
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > http://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >
> >
> --
> http://www.van-rijn.org
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help

Petr Pikal
Precheza a.s., Nabř.Dr.E.BeneÜe 24, 750 62 Přerov
tel: +420581 252 257 ; 724 008 364
petr.pikal at precheza.cz; p.pik at volny.cz
fax +420581 252 561




More information about the R-help mailing list