Is it possible to have multiple data frames to be stored into one data structure and process it later by each data frame? i.e. example
df1 <- data.frame(c(1,2,3), c(4,5,6))
df2 <- data.frame(c(11,22,33), c(44,55,66))
.. then I would like to have them added in a data structure, such that I can loop through that data structure retrieving each data frame one at a time and process it, something like
for ( iterate through the data structure) # this gives df1, then df2
{
write data frame to a file
}
I cannot find any such data structure in R. Can anyone point me to any code that illustrates the same functionality?
Just put the
data.framesin a list. A plus is that alistworks really well withapplystyle loops. For example, if you want to save the data.frame’s, you can usemapply:If you like
applystyle loops (and you will, trust me :)) please take a look at the epicplyrpackage. It might not be the fastest package (lookdata.tablefor fast), but it drips with syntactic sugar.