How to reshape a dataframe where data is arranged in "blocks" having width of x columns and length of Y rows. In this example diagram the starting dataframe is two "blocks" wide and three "blocks" long but the solution should work with other dimensions too. The final "block" may have less rows. This data-structure is obtained from the solution posted here: Split dataframe at specifi row and arrange columns into "sections" in R
I tried to reshape with reshape() into long format but could not figure out how to reorder the "blocks".
Sample data with x=2; y=6 and two "blocks" wide and two "blocks" long:
index v1 index v1
1 a 7 a
2 a 8 a
3 d 9 x
4 f 10 d
5 f 11 d
6 g 12 x
13 e 19 e
14 a 20 e
15 a 21 c
16 d
17 c
18 f
Expected output:
index v1
1 a
2 a
3 d
4 f
5 f
6 g
7 a
8 a
9 x
10 d
11 d
12 x
13 e
14 a
15 a
16 d
17 c
18 f
19 e
20 e
21 c