Quoting Eric Berger <ericjber...@gmail.com>:

Hi,
I have a list L of about 2,600 xts's.
Each xts has a single numeric column. About 90% of the xts's have
approximately 500 rows, and the rest have fewer than 500 rows.
I create a single xts using the command

myXts <- Reduce( merge.xts, L )

By default, merge.xts() does an outer join (which is what I want).

The command takes about 80 seconds to complete.
I have plenty of RAM on my computer.

Are there faster ways to accomplish this task?

Thanks,
Eric


Since you already know the number of series and all possible timestamps,
you could preallocate a matrix (number of timestamps times number of series).
You could use the fastmatch package to match the timestamps against the rows.
This what 'pricetable' in the PMwR package does.  Calling

    library("PMwR")
    do.call(pricetable, L)

should give you matrix of the merged series, with an attribute 'timestamp',
from which you could create an xts object again.

I am not sure if it is the fastest way, but it's probably faster than calling
merge repeatedly.

kind regards
    Enrico  (the maintainer of PMwR)

--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to