How to create a sequence of numbers by skipping cerain ranges in between?

Hi,

I'd like to create a sequence of numbers such that it'll run for three consecutive numbers and skip the next three and so on within a given range. For instance, if I define a range of 12 to 1000, then the series should like this:
12, 13, 14, (skipped 15, 16, 17) 18, 19, 20, (skipped 21, 22, 23) 24, 25..........1000.

I found some examples where they used functions like i++, but I didn't understand that as there were no explanations. Please let me know if this is possible to do.

Thank you in advance.

Here is one method using integer division and modulus calculations. There is probably a more elegant solution.

X <- seq(12,1000,1)
IntDiv <- X %/% 3
Mod2 <- IntDiv %% 2
X2 <- X[Mod2 == 0]
X2[1:9]
#> [1] 12 13 14 18 19 20 24 25 26
X2[487:495]
#> [1] 984 985 986 990 991 992 996 997 998

Created on 2022-08-28 by the reprex package (v2.0.1)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.