title: Parse complex text file in R
body: <p>I am looking to parse a text file in R to be loaded as a data.frame. I have a long text file with fixed width data, seperated by sections (ID) and subsections (SUB). The length of each section is variable. I'm looking to create two data frames, one for the ID section and one for the SUB section. The example data is as follows:</p>
  
  <pre><code>Header 1
  METRIC       0.30    10.00
  ID      K0107050 Aa
      0.06    15.24    14.40    14.40     7.13     0.13     0.19  1
      0.17    14.35    13.57    13.57     6.40     0.12     0.18  1
  
  SUB
      1.000   1.000  0.093  0.11  0.11 301
      1.000   1.000  0.093  0.11  0.11  61
  ID      K0129050 Aa
      0.06    26.35    24.90    24.90    10.88     0.62     0.88  1
      0.15    25.35    23.96    23.96    10.93     0.55     0.74  1
  
  SUB
      3.000   3.000  0.506  0.53  0.53 102
      4.000   4.000  0.514  0.55  0.55 118
  </code></pre>
  
  <p>The dataframe(s) I would like are:</p>
  
  <p>DF1</p>
  
  <pre><code>Header 1    K0107050    Aa    0.06    15.24    14.40    14.40     7.13     0.13     0.19  1
  Header 1    K0107050    Aa    0.17    14.35    13.57    13.57     6.40     0.12     0.18  1
  Header 1    K0129050    Aa    0.06    26.35    24.90    24.90    10.88     0.62     0.88  1
  Header 1    K0129050    Aa    0.15    25.35    23.96    23.96    10.93     0.55     0.74  1
  </code></pre>
  
  <p>DF2</p>
  
  <pre><code>Header 1    K0107050    Aa  1.000   1.000  0.093  0.11  0.11 301
  Header 1    K0107050    Aa  1.000   1.000  0.093  0.11  0.11  61
  Header 1    K0129050    Aa  3.000   3.000  0.506  0.53  0.53 102
  Header 1    K0129050    Aa  4.000   4.000  0.514  0.55  0.55 118
  </code></pre>
  
  <p>I've gotten so far as to use the readLines() but get stuck after that, given the different sections in the text file.
  Thank you</p>