title: R - from wide to long format using combinations
body: <p>Assume I have the following database <code>df</code>.</p>
  
  <pre><code>df &lt;- data.frame(ID= c("A", "B", "C"),
               Var1 = c(234, 12, 345),
               Var2 = c(4, 555, 325),
               Var3 = c("45|221|2", "982", NA))
  
  &gt; df
    ID Var1 Var2     Var3
  1  A  234    4 45|221|2
  2  B   12  555      982
  3  C  345  325     &lt;NA&gt;
  </code></pre>
  
  <p>I would like to create a data.frame in which <code>Var1</code> and <code>Var2</code> is combined with the elements in <code>Var3</code> by <code>ID</code>.</p>
  
  <p>The outcome I am looking for should look like the following:</p>
  
  <pre><code>&gt; outcome
    ID VarA VarB
  1  A  234   45
  2  A  234  221
  3  A  234    2
  4  A    4   45
  5  A    4  221
  6  A    4    2
  7  B   12  982
  8  B  555  982
  </code></pre>
  
  <p>Note that: </p>
  
  <ul>
  <li>the elements in <code>Var3</code> are separated by a vertical bar <code>|</code></li>
  <li><code>ID == C</code> is not in <code>outcome</code> because <code>Var3</code> is <code>NA</code> for that <code>ID</code>.</li>
  </ul>
  
  <p>The original data consists of millions of IDs. </p>