[R] for loop question

Thomas Lumley tlumley at u.washington.edu
Tue Sep 11 21:43:50 CEST 2001


On Tue, 11 Sep 2001, HEUMANN,JOHN (A-Loveland,ex1) wrote:

> In the windows version of R (1.3.0) is the following a bug, a
> known problem, or expected behavior:
>
>  > for (i in 1:2) {
>  + for (j in i+1:3) {
>  + print(j)
>  + }
>  + }
>  [1] 2
>  [1] 3
>  [1] 4      ????
>  [1] 3
>  [1] 4      ????
>  [1] 5      ????
>  >


It's expected behaviour (if you expect it)

Try
  i<-1
  i+1:3
  (i+1):3

to see what is going on


	-thomas


Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

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