[R-SIG-Finance] Concatenating time series objects?

Marc Delvaux mdelvaux at gmail.com
Tue Dec 2 07:48:36 CET 2008


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
>



More information about the R-SIG-Finance mailing list