title: All Levels of a Factor in a Model Matrix in R
body: <p>I have a <code>data.frame</code> consisting of numeric and factor variables as seen below.</p>
  
  <pre><code>testFrame &lt;- data.frame(First=sample(1:10, 20, replace=T),
             Second=sample(1:20, 20, replace=T), Third=sample(1:10, 20, replace=T),
             Fourth=rep(c("Alice","Bob","Charlie","David"), 5),
             Fifth=rep(c("Edward","Frank","Georgia","Hank","Isaac"),4))
  </code></pre>
  
  <p>I want to build out a <code>matrix</code> that assigns dummy variables to the factor and leaves the numeric variables alone.</p>
  
  <pre><code>model.matrix(~ First + Second + Third + Fourth + Fifth, data=testFrame)
  </code></pre>
  
  <p>As expected when running <code>lm</code> this leaves out one level of each factor as the reference level.  However, I want to build out a <code>matrix</code> with a dummy/indicator variable for every level of all the factors.  I am building this matrix for <code>glmnet</code> so I am not worried about multicollinearity.</p>
  
  <p>Is there a way to have <code>model.matrix</code> create the dummy for every level of the factor?</p>