Reputation: 1491
First of all, sorry for the title. i tried to find an appropriate title.
My "problem" is that I have a vector, say 1-5 from which I would like to make a new vector. Which goes
1, 1,2 , 1,2,3, 1,2,3,4, 1,2,3,4,5
So for each round in includes one new number from the baseline vector until it reaches the end. I have a feeling it should be possible with seq...
Upvotes: 2
Views: 433
Reputation: 25726
See ?sequence
(from the manpage):
For each element of nvec
the sequence seq_len(nvec[i])
is created. These are concatenated and the result returned.
example:
sequence(1:5)
[1] 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Upvotes: 3