[R] really dumb question | loop counters in
Evan Cooch
cooch17 at verizon.net
Fri Sep 21 22:17:10 CEST 2007
Thanks. And thanks for the C-style tip.
Greg Snow wrote:
> Try:
>
> for(x in seq(0,1,by=0.01)) {
> print(x)
> }
>
> The for loop in S/R is what some languages call a foreach loop, you need
> to provide a vector of the values to loop over.
>
> If you really want a C style for loop, then just realize that the for
> loop is a shorthand while loop:
>
> x <- 0
> while( x < 1 ) {
> print(x)
> x <- x + 0.01
> }
>
> Hope this helps,
>
>
>
More information about the R-help
mailing list