[R] Subtracting timeseries objects

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Nov 15 21:47:18 CET 2005


On Tue, 15 Nov 2005, tom wright wrote:

> Sorry to keep posting but I want to do this right and I'm hoping for
> some pointers
> I now have two time series objects which I need to subtract.
> Unfortunatly the two series dont have the same sample rates.
> When I try to subtract them
>
> avgSub<-avg1-avg2
>
> The time series object is clever enough to object.
> So I guess I need to write a function for subtraction of the time series
> objects which will need to interpolate the samples to the same sampling
> time (this linear interpolation should be ok here)
> I would like to make this function the default one to be used when a ts
> subtractin is attempted. Unfortunatly I dont really have much idea where
> to start with this. If someone could point me in the direction of some
> good reading I'll be grateful.

Subtraction is done by Ops.ts, so you need to learn up on S3 group 
generics.  That leaves you just two choices I believe, the White book and 
S Programming (details of both in the FAQ).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list