I believe my question is quite simple, but I can't manage to find the right answer.
In any given dataframe:
> data.frame(x0=c(1,2,3,4), x1=rnorm(4))
x0 x1
1 1 -0.1868765
2 2 -0.2935534
3 3 -1.3934953
4 4 0.8165035
Imagine I'd like to take every two rows and repeat it by 2 times ending up with something like this:
> data.frame(x0=c(1,2,3,4), x1=rnorm(4))
x0 x1
1 1 -0.1868765
2 2 -0.2935534
3 1 -0.1868765
4 2 -0.2935534
5 3 -1.3934953
6 4 0.8165035
7 3 -1.3934953
8 4 0.8165035
What is the easiest way to do this?
Thanks in advance!