linear interpolation of time series
zoo:::na.approx will do nicely. Though you are going to have to supply some sort of time metric or it won't know where interpolations should happen. Something like this is my usual route: x <- zoo(1:5, Sys.Date() + 2*(1:5)) x.new <- zoo(NA, seq(min(time(x)), to = max(time(x)), by = "day")) x.new[time(x)] <- x na.approx(x.new) Michael
On Sat, Dec 24, 2011 at 5:39 PM, Alemtsehai Abate <abatealem at gmail.com> wrote:
Dear R users, I have two irregular time series say x and y. Each series is supposed to cover 20 years. The data looks, for instance: x<-c(200,178, 330, 127, 420) ## only 5 observations out of the expected 20 annual values y<-c(0.35,-0.18,-0.54,0.78,1.7,-1.1,0.2,1.9,0.49)### only 9 observations of the expected 20 I need to intepolate each of the series into equally spaced 20 points. Is there a function and library in R to do this please? Many thanks Tsegaye ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.