Concatenating time series objects?
Hi Marc, rbind and cbind are particularly difficult in R. They are not true generic functions, but rather calls to .Internal code. This mean that the dispatch is very ... different :) You can try calling rbind.xts directly -- that may indeed solve your problem. This issue has been addressed in the new xts, which is being prepared for release as I type this. Basically I have added custom xts code (C code) to bypass the dispatching quirks that arise from the entire rbind->rbind.xts->rbind.zoo calling structure. Again, the look and feel of zoo will remain intact, but the underlying code is going to be different. Precisely to address issues like this that have been arising. Jeff
On Tue, Dec 2, 2008 at 12:48 AM, Marc Delvaux <mdelvaux at gmail.com> wrote:
I should have been more specific, rbind and cbind are the first solution I tried, but then the resulting object doesn't seem to be an xts :-( It mostly look like one, but str reports it as such and the time information seems lost, at least to my eye. I also tried merge, but this results in essentially a multivariate object, not in concatenation intime. see below for a toy example
seq1 <- xts(1:10,order.by=as.Date(a)) seq2 <- xts(1:10,order.by=as.Date(b)) << a and b are two consecutive sequences str(seq1)
An 'xts' object from 2008-12-02 to 2008-12-12 containing: Data: int [1:11] 1 2 3 4 5 6 7 8 9 10 ... Indexed by: Class 'Date' int [1:11] 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 ... xts Attributes: NULL
seq <- rbind(seq1, seq2)
Warning message:
number of columns of result
is not a multiple of vector length (arg 2) in: rbind(1, seq1, seq2)
str(seq)
int [1:2, 1:11] 1 1 2 2 3 3 4 4 5 5 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:2] "seq1" "seq2" ..$ : NULL
seq <- cbind(seq1, seq2)
Warning message:
number of rows of result
is not a multiple of vector length (arg 2) in: cbind(1, seq1, seq2)
str(seq)
int [1:11, 1:2] 1 2 3 4 5 6 7 8 9 10 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr [1:2] "seq1" "seq2"
On Mon, Dec 1, 2008 at 10:01 PM, Jeff Ryan <jeff.a.ryan at gmail.com> wrote:
?rbind Jeff On Mon, Dec 1, 2008 at 11:55 PM, Marc Delvaux <mdelvaux at gmail.com> wrote:
I am trying to do an incremental download of time series financial data, with say 5 new points every time I do an download. I am trying to find a simple way to perform concatenation but I cannot seem to find an easy way to do that. I did find a way using xts(c(coredata(seq1),coredata(seq2)), order.by=c(time(seq1),time(seq2))), but this loses some information that was present in seq1, and I was thinking there should be a simpler way.
_______________________________________________ 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
Jeffrey Ryan jeffrey.ryan at insightalgo.com ia: insight algorithmics www.insightalgo.com