0

I've a list with 2 dataframes of varying length and I want to split them back into individual dataframes. How do I go about doing this ?

I tried using unlist and

df <- ldply (filelist, data.frame)

but it doesn't create two individual dataframe, rather puts it all in one dataframe, also it doesn't take into consideration the | delimiter.

Dollar Vora
  • 197
  • 1
  • 10
  • Please provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output. It seems very unclear what you are asking. – MrFlick Apr 06 '17 at 18:42

1 Answers1

1

When you say split I assume you just mean turn them into objects in your global environment to call as you would the list. Let me know if this is what you mean:

somelist <- list(df1 = data.frame(woo = 1:4, waa = letters[1:4]),
                  df2 = data.frame(wee = 5:6, wii = letters[5:6]))
somelist
$df1
woo waa
1   1   a
2   2   b
3   3   c
4   4   d

$df2
wee wii
1   5   e
2   6   f

for(i in 1:length(somelist)){
  assign(names(somelist[i]), somelist[[i]])
}
[1] "df1"      "df2"      "i"        "somelist"
Evan Friedland
  • 3,062
  • 1
  • 11
  • 25