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

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Wed, 20 Apr 2011 08:27:56 -0700 (PDT)


Why not just data.matrix(UN2010) ?

> From: Haillie <nal_at_princeton.edu>
> Subject: [R] Unlist command drops all my column names in the first row and adopts NAs
> To: r-help_at_r-project.org
> Received: Wednesday, April 20, 2011, 11:05 AM
> 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.
>



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:32:35 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 - 15:40:33 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