0

Apologies in advance if this is a duplicate question, but I can't find anything on this in the stack overflow archives.

I wrote a function that returns a zoo object (makeTrace1). In a second function (make2DHist), I call this function many times and so generate a list of dataframes (converted from the returned zoo objects). I would then like to rbind all these dataframes in my list together. I can rbind specific elements together so I could do this with a for loop, but is there a vectorized expression to rbind all the dataframes in the list together?

Here's my code:

make2DHist <- function()
{

    v = list()
      times=4

    for(i in 1:times)
    {
        vv = makeTrace1()
        v[[i]] = data.frame(Date=time(vv), vv, check.names = FALSE, row.names=NULL) 

    } 

    hhh = rbind(v[[1]], v[[2]]) <-----this works
    hhh2 = rbind(v[c(1:4)]) <-this does not work


}
m= make2DHist()
3442
  • 8,248
  • 2
  • 19
  • 41

1 Answers1

1
> x <- do.call(rbind, your_list_of_matrices_or_data_frames_here)
mmuurr
  • 1,310
  • 1
  • 11
  • 21