_______________________________________________________________________________________
lower+2 : upper parses as lower + (2:upper). The colon operator has fairly high precedence. What you want is (lower + 2):upper -- Hong Ooi Senior Research Analyst, IAG Limited 388 George St, Sydney NSW 2000 +61 (2) 9292 1566 -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, 4 July 2007 10:01 AM To: r-help@stat.math.ethz.ch Subject: [R] for loop doesn't stop with upper loop value Hi list, could anyone please educate me on the following: lst<-seq(47, 239, by=12) for(n in lst) { lower=n; upper=lower+10 for(i in lower+2 : upper) { print(paste(n, " i: ", i, " lower: ",lower, " upper :", upper)) } } does not stop when i = upper A while loop fixes this but, I still don't understand why the for loop doesn't stop when I has the value of upper for(n in lst) { lower=n; upper=lower+10 while(lower !=upper +1) { print(paste(n, " lower: ",lower, " upper :", upper)) lower=lower+1 } } Any enlightment would be most welcome. Thankx Herry ______________________________________________ R-help@stat.math.ethz.ch 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. _______________________________________________________________________________________ The information transmitted in this message and its attachme...{{dropped}} ______________________________________________ R-help@stat.math.ethz.ch 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.