Create sequence of numbers, excluding certain numbers
If the numbers you want to exclude can't be generalized, @HongOoi or @James answers are the way to go. But if they can be described by some mathematical test, Filter
would be more efficient.
Filter(function(x) x %% 5 != 1, 1:85)
Using setdiff
:
setdiff(1:85,seq(1,85,5))
[1] 2 3 4 5 7 8 9 10 12 ...
(1:85)[-seq(1, 85, 5)]
or is that too obvious/inefficient?