Averaging time series with different sampling interval

I have a few time series that were (for technical reasons) acquired with slightly different time intervals, ranging between 19 and 21 seconds.

Now, I would like to average the values of these different time series over time, so I thought that I could do some sort of interpolation of the values at some regular interval (e.g. each 20 seconds).

Could someone point out a good way to do this?

Thank you

nico

The zoo package is very good at that (as is xts which extends it). The zoo vignettes have e.g. this example:

zr3 <- zooreg(rnorm(9), start=as.yearmon(2000), frequency=12)
zr3
aggregate(zr3, as.yearqtr, mean)


A (regular) series is created with monthly frequency, and the averaged by quarter. It works the very same way for POSIXct objects at much higher granularity; see the vignette. I suspect that the R-SIG-Finance list archives have plenty of related examples too.

• Thank you dirk. I suspected zoo would have something on that line, I'll have a look and see if it fits my needs. I assume it would work also for "relative" times? Each of my time series arbitrarily starts at 0s and ends at ~3500s, so I don't have precise dates. – nico Oct 28 '10 at 14:42
• I think so for as long as you can compute some indexing -- something the to-be-averaged items have in common. – Dirk Eddelbuettel Oct 28 '10 at 14:55
• Dirk, unfortunately aggregate did not solve my problem, as I want to resample at essentially the same number of points of the original trace. However I found the reglin function in pastecs that does exactly what I need! rgm2.lab.nig.ac.jp/RGM2/R_man-2.9.0/library/pastecs/man/… – nico Oct 29 '10 at 12:30