tags:

views:

38

answers:

1

A series of functions generate varying number of data frames (minimum of 1 and a max of 11). I'd like to combine them using rbind. If I knew the names, I could easily just rbind(d1,d2...) but can't do that since I have to combine a different number of data frames each time.

So lags=rbind(pattern("lags_2_Y*")) didn't work.

I can get the list of the generated lag names into a vector like so: lag_names=ls(pattern="lags_2_Y*")

If I do: lags=llply(lag_names,rbind), I just get a list with the lag names. I want to rbind the contents of those data frames.

Ideas?

+1  A: 

try

library(plyr)
lags = ldply(lag_names, get)

Edit:

If you give lag_names names, ldply() will add an id column

names(lag_names) <- lag_names

lags = ldply(lag_names, get)
JoFrhwld