title: Use R to read a text file and format extracted data in to a table
body: <p>I have a text file in the following basic format which repeats a few thousand times:</p>
  
  <pre><code>Patient Name- John Smith
  Number of dx codes: 123
  Number of pr codes: 678
  Charges: 910
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  Duis arcu ipsum, ultrices placerat mattis ac, venenatis eu magna. 
  Donec interdum iaculis lacus. Nunc in placerat augue. 
  In ut odio et dui aliquam sagittis at id augue. 
  Patient Name- Jane Smith
  Number of dx codes: 234
  Number of pr codes: 567
  Charges: 1011
  </code></pre>
  
  <p>How can I best get the above text into the following format</p>
  
  <pre><code>Patient Name    DxCodes    PrCodes    Charges
  John Smith      123        678        910
  Jane Smith      234        567        1011
  </code></pre>
  
  <p>I have been able to use str_extract from the stringi package to extract all the Patient Names into one dataframe and DxCodes, PrCodes, and Charges into another dataframe as such:</p>
  
  <pre><code>Names
  John Smith
  Jane Smith
  </code></pre>
  
  <p>And</p>
  
  <pre><code>Number of dx codes: 123
  Number of pr codes: 678
  Charges: 910
  Number of dx codes: 234
  Number of pr codes: 567
  Charges: 1011
  </code></pre>
  
  <p>But am unsure about how to proceed to get the above two dataframes into the desired format?  Should I be using a different approach from the start?
  Would definitely appreciate any help. Thank you!</p>