"Patrick E. McKnight" wrote:> > 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 Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 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 Torsten> > TIA > > Cheers, > > Patrick > > ________________________________________________________________________ > Patrick E. McKnight, Ph.D. > University of Arizona > Department of Psychology > Tucson, AZ 85721 > pem at theriver.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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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? TIA Cheers, Patrick ________________________________________________________________________ Patrick E. McKnight, Ph.D. University of Arizona Department of Psychology Tucson, AZ 85721 pem at theriver.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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> x <- rnorm(10000) > > and I want to recode all values of x > 1.5 to NA. How would I do that in R?x<-ifelse(x>1.5,NA,x) Bill -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._