I need to use rep() and seq() to get the following vector:
rep()
seq()
1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9
No
One liner,
do.call(c,sapply(1:5,seq,length.out=5,simplify=FALSE))
Or even simpler,
rep(seq(5),each=5)+seq(5)-1
> 1:5 + rep(0:4, each=5) [1] 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9