What about these two options? #One way ifelse(equated > 120, 120, equated)
#Another way equated[equated > 120] <- 120 HTH, Josh On Mon, Jul 26, 2010 at 10:26 AM, ying_chen wang <gracedrop.w...@gmail.com> wrote: > I am new to R. Used to use FORTRAN. R is so different from FORTRAN. The > following codes would work in FOTRAN. I am trying to put an upper limit at > 120. If the score is > 120, it is assigned 120. Or else, keep the original > values. > > version 1: > > equated<-11 > result<-11 > equated<-c(111.0,112.06, 112.9, 113.8, 115.0, 116.2, 117.0, 118.0, 120.5, > 120.5, 120.5) > > for (i in 1:11){ > if (equated > 120) result[i]<-120 > if (equated < 120) result[i]<-equated[i] > result<-result > result > } > result > > version2: > > if (equated > 120) result<-120 > if (equated < 120) result<-equated > > > > If any of you can help, I would appreciate that. > > G > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.