[R-SIG-Finance] Multiply xts-series with different frequencies

Jeff Ryan jeff.a.ryan at gmail.com
Wed Oct 21 16:30:57 CEST 2009


Bjørn,

na.locf(merge(hourly,daily))

Depending on how/where your hourly lines up you may need to adjust the
daily series to map to a particular hour stamp that matches the hourly
series.

HTH,
Jeff

e.g.

hourly <- xts(1:33, timeBasedSeq('2009-01-01 8/2009-01-02 16'))
daily <- xts(1:2, as.POSIXct("2009-01-01")+c(8*60*60,86400))

na.locf(merge(hourly,daily))
                    hourly daily
2009-01-01 08:00:00      1     1
2009-01-01 09:00:00      2     1
2009-01-01 10:00:00      3     1
2009-01-01 11:00:00      4     1
2009-01-01 12:00:00      5     1
2009-01-01 13:00:00      6     1
2009-01-01 14:00:00      7     1
2009-01-01 15:00:00      8     1
2009-01-01 16:00:00      9     1
2009-01-01 17:00:00     10     1
2009-01-01 18:00:00     11     1
2009-01-01 19:00:00     12     1
2009-01-01 20:00:00     13     1
2009-01-01 21:00:00     14     1
2009-01-01 22:00:00     15     1
2009-01-01 23:00:00     16     1
2009-01-02 00:00:00     17     2
2009-01-02 01:00:00     18     2
2009-01-02 02:00:00     19     2
2009-01-02 03:00:00     20     2
2009-01-02 04:00:00     21     2
2009-01-02 05:00:00     22     2
2009-01-02 06:00:00     23     2
2009-01-02 07:00:00     24     2
2009-01-02 08:00:00     25     2
2009-01-02 09:00:00     26     2
2009-01-02 10:00:00     27     2
2009-01-02 11:00:00     28     2
2009-01-02 12:00:00     29     2
2009-01-02 13:00:00     30     2
2009-01-02 14:00:00     31     2
2009-01-02 15:00:00     32     2
2009-01-02 16:00:00     33     2

On Wed, Oct 21, 2009 at 8:46 AM, Bjorn Skogtro <bjorn.skogtro at gmail.com> wrote:
> Hi all,
> is there a cleaver way to multiply two (xts) time-series with different
> frequencies?
>
> One series is hourly, and the other daily. They consist of prices and
> exchangerates, respectively, and i want to use the same exchangerate for all
> hours on the same date.
>
> Is there perhaps some way to repeat the same exchange rate for all hours the
> same day? That was my initial idea, but I'd like to manage without the
> for-loops.
>
> Thanks, and all the best!
>
> Bjørn
>
> --
> Up, down, turn around
> Please dont let me hit the ground
> Tonight I think Ill walk alone
> Ill find my soul as I go home.
>
>        [[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



More information about the R-SIG-Finance mailing list