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...
Thanks,
Katharina
###############
Background Info:
###############
sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] nlme_3.1-109 zoo_1.7-10 xlsx_0.5.1 xlsxjars_0.5.0 rJava_0.9-5
loaded via a namespace (and not attached):
[1] grid_3.0.1 lattice_0.20-15 tools_3.0.1
[[alternative HTML version deleted]]
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.
many thanks for the enlightenment - I guess I completely misunderstood the na.rm option here... On 18 June 2013 00:50, Gabor Grothendieck <ggrothendieck@gmail.com> wrote:> On Mon, Jun 17, 2013 at 6:23 PM, Katharina May > <may.katharina@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. >[[alternative HTML version deleted]]