[Rd] S4 summary method not being called (VGAM)

John Chambers jmc at r-project.org
Tue Jan 10 17:43:16 CET 2012


A relevant report, not just for VGAM but for maintainers of other 
packages that define methods for functions that have both generic and 
non-generic versions in other packages.

The problem is that VGAM "Depends" on stats4 but does not import from 
it.  So when VGAM is loaded, only the old version of summary() is 
available.  Importing the relevant functions from stats4 in VGAM should 
fix the problem.

With the current R 2.14.1 this happens silently.  With the latest 
r-devel, the installation of VGAM produces a warning:

"Functions for exporting methods must have been made generic, explicitly 
or implicitly; not true when loading 'VGAM' for 'AIC', 'coef', 'logLik', 
'plot', 'summary', 'vcov' "

This implies (a bit obscurely) that the package has generic versions in 
its dependencies, but has not imported them.

Maintainers of CRAN packages should check installation against the 
development version.  Warning messages like this suggest a problem with 
the imports.


John

On 1/9/12 5:05 PM, Mark.Bravington at csiro.au wrote:
> The symptom triggering this email is that an S4 summary method sometimes refuses to be invoked, even when a package is explicitly loaded, if the first load of the package is implicit. It may or may not be specific to 'summary' methods and/or the 'VGAM' package. I've sent to R-devel because (i) it looks like some kind of bug to me, but I'm not sure; (ii) it's not something I personally need any help with; and (iii) it seems a bit specialized for R-help.
>
> Here's the case notes. I have an object 'nf1' of S4 class 'vglm', created by calling 'vglm(...)' from package 'VGAM' (you can create your own from the examples in VGAM). It's save()d into a file "nf1.rda". If I start a new R session, call 'library( VGAM)', and then 'load("nf1.rda")', then 'summary(nf1)' works fine. But if instead I start a pretty basic R session and load() the file *without* having explicitly called library( VGAM), the summary method for 'vglm' doesn't get called whether or not I subsequently call library( VGAM). Transcript below.
>
> I'm using R 2.13.2 on Windows XP, VGAM 0.8-4. The same thing happens with R 2.15 devel v57866.
>
> bye
> Mark
>
> Mark Bravington
> CSIRO CMIS
> Marine Lab
> Hobart
> Australia
>
>
> #############################
> # Start a basic R session, and then:
>
>>   search()
>   [1] ".GlobalEnv"        "package:stats4"    "package:splines"   "package:stats"     "package:graphics"
>   [6] "package:grDevices" "package:utils"     "package:datasets"  "package:methods"   "Autoloads"         "package:base"
>
>> print( load( "nf1.rda")) # which should implicitly load VGAM, but not attach it
> [1] "nf1"
>
>> search()
> # ...snipped. No explicit VGAM
>
>> loadedNamespaces()
> # ...snipped. VGAM is there at the end.
>
>> nf1
> Call:
> vglm(formula = form, family = posbinomial, data = data, trace = TRUE)
>
> Coefficients:
> # ...snipped. The print() or show() or whatever method seems to get called OK
>
>> summary( nf1)
> Length  Class   Mode
>       1   vglm     S4
>
> # Hmmm... default method is being called, that's wrong. Try explicitly attaching 'VGAM':
>
>> library( VGAM)
> Loading required package: splines
> Loading required package: stats4
>
> Attaching package: 'VGAM'
>
> The following object(s) are masked from 'package:splines':
>
>      bs, ns
>
> The following object(s) are masked from 'package:stats':
>
>      biplot, case.names, coefficients, df.residual, fitted, fitted.values, formula, poly, residuals,
>      variable.names, weights
>
> The following object(s) are masked from 'package:base':
>
>      identity, print, scale.default
>
>> summary( nf1)
> Length  Class   Mode
>       1   vglm     S4
> # Hmmm... even though VGAM is on the search path etc, the wrong method is being called
>
> ###############################
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list