title: Converting text to a data.frame based on headers
body: <p>I uploaded a <code>.txt</code> file in to <code>R</code> as follows: <code>Election_Parties &lt;- readr::read_lines("Election_Parties.txt")</code>. Let's say the following text was in the file:</p>
  
  <pre><code>BOLIVIA
  P17-Nationalist Revolutionary Movement-Free Bolivia Movement (Movimiento Nacionalista Revolucionario 
  P19-Liberty and Justice (Libertad y Justicia [LJ])
  P20-Tupak Katari Revolutionary Movement (Movimiento Revolucionario Tupak Katari [MRTK])
  
  COLOMBIA
  P1-Democratic Aliance M-19 (Alianza Democratica M-19 [AD-M19])
  P2-National Popular Alliance (Alianza Nacional Popular [ANAPO])
  P3-Indigenous Authorities of Colombia (Autoridades Indígenas de Colombia)
  </code></pre>
  
  <p>In words: After every empty line, a new country starts. I would like to convert this text file into a dataframe where the country name becomes a vector and the list of parties becomes a vector.</p>
  
  <p>Desired output:</p>
  
  <pre><code>Bolivia     P1-Nationalist Revolutionary Movement-Free Bolivia Movement (Movimiento Nacionalista 
  Bolivia     P19-Liberty and Justice (Libertad y Justicia [LJ])
  Bolivia     P20-Tupak Katari Revolutionary Movement (Movimiento Revolucionario Tupak Katari [MRTK])
  Colombia    P1-Democratic Aliance M-19 (Alianza Democratica M-19 [AD-M19])
  Colombia    P2-National Popular Alliance (Alianza Nacional Popular [ANAPO])
  Colombia    P3-Indigenous Authorities of Colombia (Autoridades Indígenas de Colombia)
  </code></pre>
  
  <p>I would if possible like the solution to be based on the header.</p>
  
  <p>EDIT: I just realised that every new country starts with <code>P1</code>, so a solution could also be based on that.</p>