[R] for loop problem
Michael Na Li
lina at u.washington.edu
Thu Mar 6 08:01:41 CET 2003
On Tue, 04 Mar 2003, Jeremy Z. Butler told this:
> I want to generate a sequence which goes 1 2 3 4 5 6 7 8 14 15 16 17 18 19
> 20 21 26 27 ... i.e. 8 consecutive numbers then 5 missed then the next 8
> numbers etc. I was going to do this using the seq() function but couldn't
> figure out how so I thought I'd try a loop:
>
> for (x in seq(1,650,13))
> { num.set.1 <- x:x+8
^^^^^ should be x:(x+8)
> }
and by all means, avoid for loop, think in vector.
Michael
More information about the R-help
mailing list