I have data in .xlsx files that have a header structure spread over two rows:
rowid   CATA      CATB    CATC
        A1 A2 A3  B1 B2 B3  C1 C2 
1       1  1  2   2  3  5   5  6 
...
Furthermore, the number of columns (CATA CATB etc) in the first header can change across files and also the number of columns in the second header colA1 ... colC2).
In excel the first header is indicated with merged cells, delimiting the range of columns in the second header.
I have about hundred files so I would like to have an algorithm (no manual work) for getting the data structured as:
Rowid Cat  Col val 
1     CATA A1  1 
1     CATA A2  1 
1     CATA A3  2
1     CATB B1  2 
1     CATB B2  3 
1     CATB B3  5 
1     CATC C1  5 
1     CATC C2  6
What is the best way to do this in R?
 
     
    