[R] Missing values?

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Sun Oct 20 09:15:57 CEST 2002


On Sat, 19 Oct 2002, Matej Cepl wrote:

> Simple question: I have imported a table from SPSS via read.spss,
> but I have not figured out how to tell R that values 8,9 are
> considered NA.
>
> After reading help, I thought that something like
>
> is.na(data$P4)<-c(8,9)
>
> would go, but apparently it doesn't (mean gives the same value
> without regards to na.rm).

That sets NA values alternately to 8 and 9.  Try

attach(data)
P4[P4 %in% c(8, 9)] <- NA
detach()

assuming P4 is a numeric vector.

There's a section on `Re-coding Missing Values' in MASS4 that elaborates
on this.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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