This seems to be a fairly simple problem but I can't find a simple solution:
I want to repeat a data.frame (i) several times as follows:
My initial data.frame:
i <- data.frame(c("A","A","A","B","B","B","C","C","C"))
i
Printing i results in:
1 A
2 A
3 A
4 B
5 B
6 B
7 C
8 C
9 C
How I want to repeat the elements (The numbers on the first column is just for easy understanding/viewing)
i
1 A
2 A
3 A
4 B
5 B
6 B
7 C
8 C
9 C
1 A
2 A
3 A
4 B
5 B
6 B
7 C
8 C
9 C
I tried doing it using:
i[rep(seq_len(nrow(i)), each=2),]
but it provides me output as such (The numbers on the first column is just for easy understanding/viewing):
1 A
2 A
3 A
1 A
2 A
3 A
4 B
5 B
6 B
4 B
5 B
6 B
7 C
8 C
9 C
7 C
8 C
9 C
Please help!