title: R: Help using dummyVars and adding back into data.frame
body: <p>I have a data.frame of 373127 obs. of 193 variables. Some variables are factors which I want to use dummyVars() to separate each factor into its own column. I then want to merge the separate dummy variable columns back into my original data.frame, so I thought I could do the whole thing with apply, but something is not working and I can't figure out what it is.
  Sample:</p>
  
  <pre><code>dat_final &lt;- apply(dummies.var1, 1, function(x) {
    dummies.var1 &lt;- dummyVars(~ dat1$factor.var1 -1, data = dat1)
  })
  </code></pre>
  
  <p>Thanks!</p>