[R] Package zoo - na.rm ignored?

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jun 18 00:50:45 CEST 2013


On Mon, Jun 17, 2013 at 6:23 PM, Katharina May
<may.katharina at googlemail.com> wrote:
> Dear R Users,
>
> I've got a strange problem, which I do not really understand:
>
> when I use na.spline from the zoo package, the option na.rm is just being
> ignored, see this adjusted example from the na.spline help page:
> ########################
> d0 <- as.Date("2000-01-01")
> z <- zoo(c(NA, 11, 13, NA, 15, NA), d0 + 1:6)
> na.spline(z)
> na.spline(z, na.rm = FALSE)
> na.spline(z, na.rm = T)
> #######################
>
> In all 3 cases, the output looks like this with the trailing NA being
> replaced:
> 2000-01-02 2000-01-03 2000-01-04 2000-01-05 2000-01-06 2000-01-07
>   8.333333  11.000000  13.000000  14.333333  15.000000  15.000000
>
> Am I missing something here?
> Any help is very much appreciated...
>

If the result of the spline interpolation still results in NAs then
na.rm=TRUE will remove any leading NAs.  It may be that all currently
supported methods produce no NAs in which case this argument would
only be there for compatability with na.approx and in case future
additional spline methods do produce NAs.



More information about the R-help mailing list