I have a climate time series with missing Dates (not missing values). For example:
n = 15
full.dates = seq(Sys.Date(), by = 'day', length = n)
serie.dates = full.dates[c(1:10, 12, 15)] # missing 11, 13, 14
y = rnorm(n)
require(zoo)
serie = zoo(y, serie.dates)
How can i 'fill' (using interpolation) these missing points, given the 'full.dates' vector? Thanks!
Merge with an "empty" object that has all the dates you want, then use na.approx
(or na.spline
, etc.) to fill in the missing values.
x <- merge(serie, zoo(,seq(start(serie),end(serie),by="day")), all=TRUE)
x <- na.approx(x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With