[R] Merging lot of zoo objects

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jul 21 14:13:04 CEST 2009


1. If the series are zoo series all starting with z, say, in the
current workspace then:

L <- sapply(ls(pattern = "^z"), get, simplify = FALSE)
znew <- do.call("merge", L)

2. If your data originally comes from a single file with
a column that specifies which series that row pertains
to then you can use read.zoo from the devel version of
zoo with the split= argument.

# all price series are in one file with
# second column containing series id
library(zoo)
source("http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/R/read.zoo.R?rev=588&root=zoo")
znew <- read.zoo("myfile", split = 2, ...whatever...)


On Tue, Jul 21, 2009 at 3:07 AM, RON70<ron_michael70 at yahoo.com> wrote:
>
> Hi,
>
> I have 100 price data series like price1, price2, price3, ............. All
> are "zoo" objects. Now I want to merge all them together. Obviously I can do
> this using "merge(price1, price2, price3, ........)". However as I have lot
> of price series (almost 1000) above systax is very tiresome. Is there any
> other way on doing to in one-go?




More information about the R-help mailing list