[R] tabulate means & NA

Dr. Diego Kuonen kuonen at statoo.com
Thu Jun 20 11:32:30 CEST 2002


Christian Schulz wrote:
> 
> i have some problems to get means, but the data have got
> NA's  which should not be replaced or delete !
> 
> tapply(data,var,mean)     # makes me problem,because when one value is
> NA mean is NA,too.

You may want to have a look at the mean help page (?mean) and
add `na.rm = TRUE' to the `tapply' call, i.e.

  tapply(data, var, mean, na.rm=TRUE)

You might also want to read the help pages for `na.action', `na.omit', 
`na.fail' on how methods can be tuned to deal with missing values.

Greets,

  Diego Kuonen


-- 
Dr. ès sc. Diego Kuonen        CEO & Applied Statistician 
Statoo Consulting, PO Box 107, 1015 Lausanne, Switzerland
+ Have you ever been Statooed?   http://www.statoo.info +
+ Free Statooed newsletters:    http://lists.statoo.com +
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list