Hi, Is this what you want? matrix(unlist(myList),nr=1) Miguel
On Thu, Mar 11, 2010 at 4:03 PM, anna <lippelann...@hotmail.com> wrote: > > Hi guys, here is a list of names that I have: > > MyList: > > myList<-list("A", "B","C","D") > > myList > [[1]] > [1] "A" > > [[2]] > [1] "B" > > [[3]] > [1] "C" > > [[4]] > [1] "D" > > I want to turn this list into a matrix of 1 row and 4 columns with those > four components (A, B, C, D) so here is what I do: > > myDataFrame <- data.frame(myList) and here is how myDataFrame looks like: > > myDataFrame > X.A. X.B. X.C. X.D. > 1 A B C D > > Until that point everything is ok because if I want to retrieve one element > I make > > myDataFrame[[1]] > [1] A > Levels: A > > But when I try to convert into matrix by doing this: > > > myMatrix <- data.matrix(myDataFrame) I get this: > > myMatrix > X.A. X.B. X.C. X.D. > [1,] 1 1 1 1 > He just keeps the names and delete the components...What am I doing wrong? > Thanks in advance! > > > > > > > > > > > > > > ----- > Anna Lippel > -- > View this message in context: > http://n4.nabble.com/Can-t-convert-list-to-matrix-properly-tp1589187p1589187.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]] ______________________________________________ R-help@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.