title: How to convert dataframe of mostly factors into numeric matrix; unlist is not working
body: <p>I am having trouble turning my <code>data.frame</code> into a matrix format. Because I wanted to change my data.frame with mostly factor variables into a numeric matrix, I used the following code</p>
  
  <pre><code>UN2010frame &lt;- data.matrix(lapply(UN2010, as.numeric))
  </code></pre>
  
  <p>However when I checked the mode of the <code>UN2010frame</code>, it still showed up as a list. Because the code I want to run (Ordrating) does not accept data in a list format, I used <code>UN2010matrix &lt;- unlist(UN2010frame)</code> to unlist my matrix. When I did this, my first row ( which was formerly a row with column names) turned into NAs. This was a problem for me because when I tried to run an ordinal IRT model using this data set, I got the following error message. </p>
  
  <pre><code>&gt; Error in 1:nrow(Y) : argument of
  &gt; length 0
  </code></pre>
  
  <p>I think it is because all the values in my first row are now gone.</p>
  
  <p>If you could help me on any front, It would be deeply appreciated. 
  Thank you very much!</p>
  
  <p>Haillie </p>