I have a data frame like this:
data <- tibble(var = c("a", "b", "c"))
var
<chr>
1 a
2 b
3 c
Now I want du duplicate each row three times, so I ran this code
data <- tibble(var = c("a", "b", "c")) %>%
slice(rep(1:n(), each = 3))
The result is this:
var
<chr>
1 a
2 a
3 a
4 b
5 b
6 b
7 c
8 c
9 c
But I want is this:
var
<chr>
1 a
2 b
3 c
4 a
5 b
6 c
7 a
8 b
9 c
Thanks in advance, I appreciate any kind of help.
Cheers