On Fri, Jan 7, 2011 at 1:01 PM, Pete B <peter.breckn...@bp.com> wrote: > > Hi > > I have n zoo objects M1, M2, M3, ... , Mn that I want to merge where n is a > number calculated at run-time. > > I am struggling to find the correct syntax to do this > > Assuming n is calculated as 10 (for example), I have tried > > n = 10 > # First Effort > alldata= merge(paste("M",rep(1:n), sep=""),all=TRUE) > > # Second Effort > alldata > =merge(noquote(toString(paste("M",rep(1:nrow(counts1)),sep=""))),all=TRUE) >
Try this where the sapply creates a list of the objects. library(zoo) M1 <- zoo(11:13); M2 <- zoo(21:24); M3 <- zoo(31:35) do.call("merge", sapply(ls(pattern = "^M"), get, simplify = FALSE)) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.