[R] jump in sequence

Ben Fairbank BEN at SSANET.COM
Tue Jan 30 16:38:28 CET 2007

Or perhaps


with changes as necessary for longer sequences

Ben Fairbank

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Adrian DUSA
Sent: Tuesday, January 30, 2007 8:29 AM
To: r-help at stat.math.ethz.ch
Subject: [R] jump in sequence

Dear list,

This should be a simple one, I just cannot see it.
I need to generate a sequence of the form:
4  5  6 13 14 15 22 23 24

That is: starting with 4, make a 3 numbers sequence, jump 6, then
another 3
and so on.
I can create a whole vector with:
myvec <- rep(rep(c(F, T, F), rep(3, 3)), 3)

Then see which are TRUE:
[1]  4  5  6 13 14 15 22 23 24

I'd like to avoid creating the whole vector if possible; for very large
it can be time consuming. There should be a way to only create the

Thanks for any hint,

Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Tel./Fax: +40 21 3126618 \
          +40 21 3120210 / int.101

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list