I have a vector e.g:
v <- c(1, 2, 3, 4)
I want to repeat the sequence of every nth element x times e.g:
x=2
n= 2
[1] 1, 2, 1, 2, 3, 4, 3, 4
I know that
rep(v, times=n)
[1] 1, 2, 3, 4, 1, 2, 3, 4
rep(v, each=n)
[1] 1, 1, 2, 2, 3, 3, 4, 4
Thanks!