Skip to content
Prev 4958 / 15274 Next

interpolating missing values from a TS

Try this (time series with values of 2, NA , etc. at indicated times
(1, 3, etc.) which has NAs removed by linear approx:
1        3        4        6        7        8
2.000000 1.333333 1.000000 4.000000 5.000000 2.000000

zoo has otherl na.* routines too.  They work the same way.  You just
give them the series and the NAs are filled in as in the example
above.

na.approx - linear approximation to NAs
na.contiguous - only keep portion of series with no NAs
na.locf - fill NAs from last non-NA
na.omit - remove NAs
na.spline - spline approximation to NAs
na.trim - remove NAs at ends

And also in the stinepack package:

na.stinterp - use Stineman approxmation to remove NAs

See ?na.approx for a few more examples.
On Wed, Oct 7, 2009 at 5:23 AM, Aleks Clark <aleks.clark at gmail.com> wrote: