[R] Want to convert list with vectore of dis similar lengths to data frame

harini_v harini.v at positiveintegers.com
Thu Mar 5 10:53:56 CET 2015


Hi there

I am Ms. Harini and I am trying to solve a problem with the function
data.frame. The problem I am trying to solve is similar to the one listed
under the title Example Four in this website: 
http://www.r-bloggers.com/converting-a-list-to-a-data-frame/

For some reason when I try to replicate the results in my R console, I get
this error:
test4 <- list('Row1'=letters[1:5], 'Row2'=letters[1:7],
'Row3'=letters[8:14])

as.data.frame(test4)

Error in data.frame(Row1 = c("a", "b", "c", "d", "e"), Row2 = c("a", "b",  : 
  arguments imply differing number of rows: 5, 7

It says that it can’t do what I am asking it to do because the lengths of
the rows are different. But somehow it has worked on the above website.

This is an old article (written in 2013). My question is this: Would you
know if the way data.frame handles lists has been re written in some way? I
couldn’t find anything to answer my question on the web, so I thought I
should email you.

Thank you for the time you are taking to read my email and trying to help
me.
Sincerely,
Harini




--
View this message in context: http://r.789695.n4.nabble.com/Want-to-convert-list-with-vectore-of-dis-similar-lengths-to-data-frame-tp4704196.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list