[Rd] S3 weirdness
Simon Urbanek
@|mon@urb@nek @end|ng |rom R-project@org
Fri Jun 25 00:51:17 CEST 2021
Gabor,
just by using zoo::read.zoo() you *do* load the namespace:
> args(zoo::read.zoo)
function (file, format = "", tz = "", FUN = NULL, regular = FALSE,
index.column = 1, drop = TRUE, FUN2 = NULL, split = NULL,
aggregate = FALSE, ..., text, read = read.table)
NULL
> sessionInfo()
R Under development (unstable) (2021-06-23 r80548)
Platform: x86_64-apple-darwin19.6.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /Volumes/Builds/R/build/lib/libRblas.dylib
LAPACK: /Volumes/Builds/R/build/lib/libRlapack.dylib
locale:
[1] en_NZ.UTF-8/en_NZ.UTF-8/en_NZ.UTF-8/C/en_NZ.UTF-8/en_NZ.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] zoo_1.8-9 compiler_4.2.0 grid_4.2.0 lattice_0.20-44
which includes S3 method dispatch tables:
> methods(as.ts)
[1] as.ts.default* as.ts.zoo* as.ts.zooreg*
see '?methods' for accessing help and source code
so the behavior is as expected.
Cheers,
Simon
> On 25/06/2021, at 9:56 AM, Gabor Grothendieck <ggrothendieck using gmail.com> wrote:
>
> If we start up a vanilla session of R with no packages loaded and
> type the single line of code below as the first line entered then
> we get the output shown below. The NA in the output and the length
> of 7 indicate that as.ts dispatched as.ts.zoo since as.ts.default
> would have resulted in a length of 6 with no NA's. It should not have
> known about as.ts.zoo since we never explicitly loaded the zoo
> package using library or require.
> zoo:: was only used to refer to read.zoo. This seems to be a bug in
> the way R is currently working.
>
> as.ts(zoo::read.zoo(BOD))
> ## Time Series:
> ## Start = 1
> ## End = 7
> ## Frequency = 1
> ## [1] 8.3 10.3 19.0 16.0 15.6 NA 19.8
>
> R.version.string
> ## [1] "R version 4.1.0 RC (2021-05-16 r80303)"
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
More information about the R-devel
mailing list