title: pivot_longer with a very big data.frame, memory efficient approaches
body: <p>I have a <code>data.frame</code> of hospital data with 11 million rows.</p>
  <pre><code>Columns: ID (chr), outcome (1|0), 20x ICD-10 codes (chr).
  Rows: 10.6 million
  </code></pre>
  <p>I wish to make the data tidy to allow modelling of diagnostic codes to a binary outcome.</p>
  <p>I would normally use <code>pivot_longer</code> or Base R <code>aggregate</code> function, but the resulting <code>data.frame</code> is huge and my machine struggles, due to memory (32gb RAM, windows server running latest R x64).</p>
  <p>I am going to split the <code>data.frame</code> and <code>pivot_longer</code> for each and manually add columns to allow binding <code>data.frame</code>'s after, or to model each split <code>data.frame</code> separately.</p>
  <p>Is there a method I could use instead to reduce the data size or achieve a similar objective which I am missing?</p>