[Rd] warning creating an as.array method in a package

Michael Friendly friendly at yorku.ca
Thu Dec 9 16:05:50 CET 2010

I posted on this topic to r-help, but never got a sufficient answer, so 
I'm reposting here.

[Env:  R 2.11.1, Win Xp, using Eclipse/StatET]

In a package I'm working on, I want to create as.matrix() and as.array() 
methods for a particular kind of
object (log odds ratios). These are returned in a loddsratio object as 
the $coefficients component,
a vector, but really reflect an underlying (R-1)x(C-1)xstrata array, 
whose attributes are contained in other components.

These are all properly declared in the NAMESPACE as S3 methods,

S3method(dim, loddsratio)
S3method(dimnames, loddsratio)
S3method(print, loddsratio)
S3method(vcov, loddsratio)
S3method(as.matrix, loddsratio)
S3method(as.array, loddsratio)

Yet, when I run R CMD check, R CMD build, etc. or even load the package, 
I get the warning,

 > library(vcdExtra)
Loading required package: vcd
Loading required package: MASS
Loading required package: grid
Loading required package: colorspace
Loading required package: gnm
Warning message:
found an S4 version of ‘as.array’ so it has not been imported correctly

 > showMethods("as.array")
Function: as.array (package base)

But as.array does show up as a method for my class:

 > methods(class="loddsratio")
[1] as.array.loddsratio*      as.data.frame.loddsratio*
[3] as.matrix.loddsratio*     coef.loddsratio*
[5] confint.loddsratio*       dim.loddsratio*
[7] dimnames.loddsratio*      print.loddsratio*
[9] vcov.loddsratio*

    Non-visible functions are asterisked

Is there some work-around so I can have an S3 as.array() method in my 
package and avoid this warning?

Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

More information about the R-devel mailing list