[R] apply
Liaw, Andy
andy_liaw at merck.com
Thu Apr 7 15:32:30 CEST 2005
> From: malte
>
> Hi,
>
> simple question I guess:
>
> the following line works well:
>
> aveBehav=c(apply(sdata, 2, mean))
>
> However, I would like to pass an argument to the function
> mean, namely
> na.rm=TRUE
>
> Does anyone knows how to do this?
aveBehav <- apply(sdata, 2, mean, na.rm=TRUE)
or more efficiently:
aveBehav <- colMeans(sdata, na.rm=TRUE)
Read ?apply and look at the "..." argument. If you don't understand how it
works, try the example on that page.
Andy
> Thanks in advance,
>
> Jan
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
>
More information about the R-help
mailing list