Skip to content
Prev 78481 / 398502 Next

Interpolation in time

Is doy intended to represent the number of days since the beginning
of the year?  In that case convert the first two columns to class Date
and interpolate using approx.  See ?approx for variations:

tt <- as.Date(paste(yr, 1, 1, sep = "-")) + doy - 1
ta[,"dat"] <- approx(tt, dat, tt)$y

Even better would be to create an irregular time series object.

library(zoo)
tt <- as.Date(paste(yr, 1, 1, sep = "-")) + doy - 1
ta.z <- na.approx(zoo(dat, tt))

Now ta.z is a zoo object representing your time series. coredata(ta.z)
is the data and time(ta.z) are the dates.  See:

library(zoo)
vignette("zoo")

for more info.
On 10/6/05, Anette N??rgaard <anette at geoplus.dk> wrote: