Skip to content
Prev 374402 / 398513 Next

Converting a list to a data frame

Another approach:

########
library(tidyr)
L <- list( A = data.frame( x=1:2, y=3:4 )
          , B = data.frame( x=5:6, y=7:8 )
          )
D <- data.frame( Type = names( L )
                , stringsAsFactors = FALSE
                )
D$data <- L
unnest(D, data)
#>   Type x y
#> 1    A 1 3
#> 2    A 2 4
#> 3    B 5 7
#> 4    B 6 8
########
On Wed, 2 May 2018, Eivind K. Dovik wrote:

            
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k