merging a list of xts objects
As L is now a list, you lose the xts dispatch.
Try:
do.call("merge",L)
X1.1 X1.2 X1.3 X1.4 X2.1 X2.2 X2.3 X2.4 X3.1 X3.2 X3.3 X3.4
2009-10-19 1 1 1 1 2 2 2 2 3 3 3 3
2009-10-20 1 1 1 1 2 2 2 2 3 3 3 3
2009-10-21 1 1 1 1 2 2 2 2 3 3 3 3
2009-10-22 1 1 1 1 2 2 2 2 3 3 3 3
2009-10-23 1 1 1 1 2 2 2 2 3 3 3 3
2009-10-24 1 1 1 1 2 2 2 2 3 3 3 3
2009-10-25 1 1 1 1 2 2 2 2 3 3 3 3
2009-10-26 1 1 1 1 2 2 2 2 3 3 3 3
2009-10-27 1 1 1 1 2 2 2 2 3 3 3 3
2009-10-28 1 1 1 1 2 2 2 2 3 3 3 3
HTH
Jeff
On Thu, Oct 29, 2009 at 8:46 PM, Jiri Hoogland <jiri.hoogland at gmail.com> wrote:
Hi,
i thought this should be pretty trivial, but i am missing something here
Why can't ?I merge a list L of xts objects (all even with the same index)
Thanks,
Jiri
# code
library(xts)
random.xts <- function(x0=1.0,n=100,k=10,c="A",rnd=F) {
?n.c <- length(c)*k
?if (rnd)
? ?x <- matrix(rnorm(n*n.c,x0,1),n,n.c)
?else
? ?x <- matrix(x0,n,n.c)
?t <- Sys.Date() - (1:n) -1
?x <- xts(x,t)
?colnames(x) <- paste(c,1:n.c,sep=".")
?return(x)
}
test <- function(n=10,k=4,c=3) {
?lapply(c(1:c),function(x) random.xts(x,n,k,paste(x)))
}
L <- test()
merge(L)
? ? ? ?[[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
Jeffrey Ryan jeffrey.ryan at insightalgo.com ia: insight algorithmics www.insightalgo.com