[R] Unlist command drops all my column names in the first row and adopts NAs

From: Haillie <nal_at_princeton.edu>
Date: Wed, 20 Apr 2011 08:05:26 -0700 (PDT)


Hi Everyone,

I am having trouble turning my data.frame 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 -->
UN2010frame<-data.matrix(lapply(UN2010,as.numeric))

However when i checked the mode of the UN2010frame, 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 UN2010matrix <- unlist(UN2010frame) 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.

Error in 1:nrow(Y) : argument of length 0

I think it is because all the values in my first row are now gone....

If you could help me on any front, It would be deeply appreciated. Thank you very much!

Haillie

--
View this message in context: http://r.789695.n4.nabble.com/Unlist-command-drops-all-my-column-names-in-the-first-row-and-adopts-NAs-tp3463294p3463294.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 20 Apr 2011 - 15:07:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Apr 2011 - 16:00:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive