Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R, how to create a sequence of numbers with gaps in it? [duplicate]

Tags:

r

seq

How to efficiently generate the following sequence of numbers in R? 4, 5, 10, 11, 16, 17, ..., 178, 179

like image 994
Joe Avatar asked Oct 30 '25 13:10

Joe


1 Answers

One way is to think of it as the union of two sequences.

sort(c(seq(4,178,6), seq(5,179,6)))
 [1]   4   5  10  11  16  17  22  23  28  29  34  35  40  41  46  47  52  53  58
[20]  59  64  65  70  71  76  77  82  83  88  89  94  95 100 101 106 107 112 113
[39] 118 119 124 125 130 131 136 137 142 143 148 149 154 155 160 161 166 167 172
[58] 173 178 179
like image 108
G5W Avatar answered Nov 02 '25 04:11

G5W