[R] generate sequences for every element of a vector

Martin Batholdy batholdy at googlemail.com
Fri Oct 7 15:40:03 CEST 2011


Dear R-List,


I have the following problem:

I have a vector that looks like this:

x <- c(3, 8, 14, 24, 34, 40)


And I would like to make a sequence out of every element, starting at the value of this element.

So that I get a vector just like this:

x <- c(3, 4, 5,     8, 9, 10,      14, 15, 16,       24, 25, 26,       34, 35, 36,      40, 41, 42)




How can I do this without looping over the whole vector or something like this?


thanks for any suggestions!


More information about the R-help mailing list