I would like to make the following sequence in R, by using rep or any other function.
[1, 2, 3, 4, 5, 2, 3, 4, 5, 3, 4, 5, 4, 5, 5]
Basically, c(1:5, 2:5, 3:5, 4:5, 5:5).
>Solution :
Use sequence.
sequence(5:1, 1:5)
[1] 1 2 3 4 5 2 3 4 5 3 4 5 4 5 5
The first argument (5:1) is the length of each sequence, the second (1:5) is the starting point.