title: Trying to make a new dataframe with less observations but more columns
body: <p>I am new to R and I have this data frame that I am using to make another one.  I am not sure how to ask this question so I figured I would give an example:</p>
  <pre><code>MRN &lt;- c(1,1,1,2,3,5,5)
  Comorbid &lt;- c(&quot;Celiac&quot;, &quot;T1D&quot;, &quot;Hashimoto&quot;, &quot;Celiac&quot;, &quot;EoE&quot;, &quot;Celiac&quot;, &quot;Graves&quot;)
  df2 &lt;- data.frame(MRN, Comorbid)
  
  MRN &lt;- c(1,2,3,4,5)
  Celiac &lt;- c(1,1,0,0,1)
  T1D &lt;- c(1,0,0,0,0)
  Hashimoto &lt;- c(1,0,0,0,0)
  EoE &lt;- c(0,0,1,0,0)
  Graves &lt;- c(0,0,0,0,1)
  df3 &lt;- data.frame(MRN,Celiac,T1D,Hashimoto,EoE,Graves)
  </code></pre>
  <p>I have included pictures of both the dataframes below:</p>
  <p><a href="https://i.stack.imgur.com/wuVA5.png" rel="nofollow noreferrer">enter image description here</a>
  <a href="https://i.stack.imgur.com/VO5wO.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>I am trying to make df3 from df2.  Any idea how to do this?</p>
  <p>Thanks!</p>