[R] recode vector values to NA

Mark Myatt mark at myatt.demon.co.uk
Tue Mar 27 11:17:41 CEST 2001


Patrick E. McKnight <pem at theriver.com> writes:
>Greetings,
>
>I'm in the painful process of migrating from SAS to R.  In the process I've
>discovered that there are some basic things that I am getting hung up on.  The
>most basic is the simple recoding of variables.  Suppose I create a vector
>
>  x <- rnorm(10000)
>
>and I want to recode all values of x > 1.5 to NA.  How would I do that in R? 

        x[x > 1.5] <- NA



--
Mark Myatt


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