Re: [R] how to interpolate time series data with missingness

2009-06-17 Thread Matthew Keller
Excellent. Thank you. I have been messing around with loess() but this looks quicker. Thanks, Matt On Wed, Jun 17, 2009 at 4:07 PM, Gabor Grothendieck wrote: > The zoo package has a number of na.* routines: > >> library(zoo) >> x <- c(2,3,NA,NA,NA,3.2,3.5,NA,NA,6,NA) >> na.approx(x) >  [1] 2.

Re: [R] how to interpolate time series data with missingness

2009-06-17 Thread Gabor Grothendieck
The zoo package has a number of na.* routines: > library(zoo) > x <- c(2,3,NA,NA,NA,3.2,3.5,NA,NA,6,NA) > na.approx(x) [1] 2.00 3.00 3.05 3.10 3.15 3.20 3.50 4.33 [9] 5.17 6.00 > na.locf(x) [1] 2.0 3.0 3.0 3.0 3.0 3.2 3.5 3.5 3.5 6.0 6.0 > na.spline(x) [

[R] how to interpolate time series data with missingness

2009-06-17 Thread Matthew Keller
Hi all, I have a vector, most of which is missing. The data is always increasing, but may do so in jumps. I would like to interpolate the NAs with 'best guesses', using something like filter(), which doesn't work due to the NAs. Here is an example: > x <- c(2,3,NA,NA,NA,3.2,3.5,NA,NA,6,NA) > x [