Description Usage Arguments Value Author(s) References Examples
Convert a List to a Data Frame
1 2 | ## S3 method for class 'list'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)
|
x |
a list to convert to a data frame. |
row.names |
a vector equal to |
optional |
not used. |
... |
other parameters passed to |
a data frame.
Jason Bryer <<jason@bryer.org>>
http://stackoverflow.com/questions/4227223/r-list-to-data-frame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | test1 <- list( c(a='a',b='b',c='c'), c(a='d',b='e',c='f'))
as.data.frame(test1)
test2 <- list( c('a','b','c'), c(a='d',b='e',c='f'))
as.data.frame(test2)
test3 <- list('Row1'=c(a='a',b='b',c='c'), 'Row2'=c(var1='d',var2='e',var3='f'))
as.data.frame(test3)
test4 <- list('Row1'=letters[1:5], 'Row2'=letters[1:7], 'Row3'=letters[8:14])
as.data.frame(test4)
test5 <- list(letters[1:10], letters[11:20])
as.data.frame(test5)
test6 <- list(list(letters), letters)
as.data.frame(test6)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.