Dirk Eddelbuettel wrote:
Yes, arithmetic operations are defined for DateTimeClasses, which is what is used underneath the its object. It is not always obvious how to milk this, but note how help("DateTimeClasses") shows a few things, and refers to a few other help pages. Just to give one idea:
seq(Sys.Date(), by="week", length=3)
 "2004-10-26" "2004-11-02" "2004-11-09"
Sys.Date() returns a "Date" object, which is a POSIXt, for which a seq.POSIXt() exists -- and so you create sequences. Likewise there are operators for differences etc pp.
the posix time_t and struct tm's are fine for dates/timestamps, but not for calendaring ...more below.
There is quite a bit of calendaring code in fBasics, the first of ouri snatched it(fBasics) and reviewed/tested and don't see the needed functionality...and the wheel is already invented in my case, and deployed round the globe at client cites. Just figure'd on sharing it if needed/wanted...
modules from www.Rmetrics.org (and also on CRAN). Maybe you could review
that functionality, see what is missing and contribute to it? Just a
suggestions to avoid yet another reinvented wheel ...
Like me, you read too damn fast :) The question was not for the weekly moving avg, but the moving average of weekly volume. So, for weekly time-series(ending on fridays) i want to see the moving average of the aggregate weekly volumes. What you indicate above seems to give me the moving average of the values on one day of each week? Am i wrong...
One other question: i notice that the computeXXX functions all take the data represented as business frequency. Is there a good way to handle time-scaling w/ its (or other R pkg) to handle simple meta-data like how time-series are observed, i.e., closes mark the end of a time interval, highs the high for an interval, volume the aggregate for the interval...etc...
E.g., calc the moving average of weekly volume for a stock?
Maybe in two steps: use rangeIts() to extract at weekly intervals, and then use filter() to compute the running moving average?
The most simple of examples:
ibm stock measured @ business day freq: (imagine dates attached)
date open high low close volume ------- ------ ----- ----- ------ ---------- mon 5 6 4 5.5 100 tues 5 7 5 6.5 200 wed 6.5 7.5 6 7 200 thur 6.5 6.5 6 6 500 fri ----<holiday>---
converted to a weekly(friday) time series
date open high low close volume ------- ------ ----- ----- ------ ---------- wk(1) 5 7.5 4 6 1000 ...
./configure make make check make install
and then i could give you a simple R wrapper to give it a go?