[R-SIG-Finance] Writing code that works with a variety of time series classes

Ajay Shah ajayshah at mayin.org
Sat Oct 4 20:14:53 CEST 2008


I'm writing a function where I want to support two cases:
    - caller supplies a pure numeric
or
    - caller supplies a time series object

For the latter case, R now has a variety of time series classes : ts,
zoo, its, xts, etc. I only require two operations: 

     I want to pull out the datetime stamps (e.g. index(a.zoo))
     I want to then convert down to a numeric (e.g. as.numeric(a.zoo))

Between all the people building time series classes, is there an
agreement on some minimal set of functions that will always be
supported? Do index(z) and as.numeric(z) work consistently across all
the time series classes? And, I think we need a function is.tsclass()
which reports TRUE if the object supplied is a zoo, its, ts or xts.

-- 
Ajay Shah                                      http://www.mayin.org/ajayshah  
ajayshah at mayin.org                             http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.



More information about the R-SIG-Finance mailing list