I need to read in a datafile with 2 levels of headers, the data looks like this:
| | Jone Doe | | | | | | | Jane Doe | | | | | | |
|----------|----------|------|------|------|------|------|------|----------|------|------|------|------|------|------|
| Date | Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | Col7 | Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | Col7 |
| 1-Jul-13 | 49 | 42 | 20 | 18 | 23 | 16 | 29 | 48 | 33 | 24 | 10 | 43 | 13 | 43 |
| 2-Jul-13 | 17 | 16 | 43 | 33 | 37 | 37 | 10 | 7 | 45 | 19 | 4 | 41 | 41 | 20 |
| 3-Jul-13 | 35 | 39 | 42 | 35 | 5 | 12 | 22 | 3 | 28 | 23 | 10 | 12 | 5 | 8 |
I need it to look like this:
| Date | Name | Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | Col7 |
|----------|----------|------|------|------|------|------|------|------|
| 1-Jul-13 | Jone Doe | 49 | 42 | 20 | 18 | 23 | 16 | 29 |
| 2-Jul-13 | Jone Doe | 17 | 16 | 43 | 33 | 37 | 37 | 10 |
| 3-Jul-13 | Jone Doe | 35 | 39 | 42 | 35 | 5 | 12 | 22 |
| 1-Jul-13 | Jane Doe | 48 | 33 | 24 | 10 | 43 | 13 | 43 |
| 2-Jul-13 | Jane Doe | 7 | 45 | 19 | 4 | 41 | 41 | 20 |
| 3-Jul-13 | Jane Doe | 3 | 28 | 23 | 10 | 12 | 5 | 8 |
Any idea on how to do this without hard-coding? I've been trying using melt() and gather() without any luck
Edit:
Sample data : https://drive.google.com/open?id=1T4KkAk5D55_nXsHlr1Aozed6d49qFM_8
output of nm1:
[1] "John Doe" "John Doe" "John Doe" "John Doe" "John Doe" "John Doe" "John Doe" "Jane Doe"
[9] "Jane Doe" "Jane Doe" "Jane Doe" "Jane Doe" "Jane Doe" "Jane Doe" "Jose Doe" "Jose Doe"
[17] "Jose Doe" "Jose Doe" "Jose Doe" "Jose Doe" "Jose Doe" "Jacob Doe" "Jacob Doe" "Jacob Doe"
[25] "Jacob Doe" "Jacob Doe" "Jacob Doe" "Jacob Doe"