[R-SIG-Finance] insert element in IBrokers/XTS time series?

Sean Carmody seancarmody at gmail.com
Sat Jul 4 11:26:10 CEST 2009


Eliminating a row is straightforward, e.g.

myhist[time(myhist) != as.Date("2009-06-29"),]

will return everything except the entry for 2009-06-29.

Adding a row is, I believe, a bit more fiddly. You can use

rbind(myhist, xts(data.frame(rep(NA,6), order.by=as.Date("2009-08-01")))

although this will give a warning message about column names
differing. If you have an additional xts with the same column names,
you can simply use merge()

Sean.

On Sat, Jul 4, 2009 at 10:01 AM, Michael<comtech.usa at gmail.com> wrote:
> Hi all,
>
> Let's say I have the following timeseres in IBrokers and XTS:
>
> 2009-06-25      18038      18350     18011       18327         5396     18183
> 2009-06-26      18420      18708     18331       18515         7367     18499
> 2009-06-29      18546      18688     18423       18577        28728     18555
> 2009-07-03      17951      18198     17866       18149        38019     18059
>
> I want to add a few more rows, indexed by
>
> "2009-06-30", "2009-07-01", "2009-07-02", and using NA's,
>
> I did the following:
>
> myhist["2009-07-01",]=c(NA, NA, NA, NA, NA, NA, NA, NA)
>
> But it didn't really work.
>
> What's the good way to insert missing points in time series?
>
> Thanks!
>
> _______________________________________________
> 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.
>



-- 
Sean Carmody

The Stubborn Mule
http://www.stubbornmule.net
http://twitter.com/seancarmody



More information about the R-SIG-Finance mailing list