Skip to Content

changing repeats in a sequence

I have the following vector

328 328 328 328 337 338 339 340 341 342 343 344 345 346 347 348 349 349 349 349 349 349 349 349 349 349 349 349

As you can see, 328 is repeated 4 times and 349 is repeated 12 times. I was wondering what's the most efficient way in R to renumber the 328 so that it is 328,329,330,331, and the 349's would be 349,350,351,...

I can do this using a for loop but I have a feeling R has a more "R-centric" approach.