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

Michael Friendly friendly at yorku.ca
Thu Dec 2 14:58:06 CET 2010

On 11/30/2010 5:59 PM, David Winsemius wrote:
> I'm guessing from this behavior on my system that it may be Matrix.
>  > showMethods(as.array)
> Function: as.array (package base)
> x="ANY"
> x="Matrix"
I'm still perplexed by this.  Running R CMD install gives this warning:
** testing if installed package can be loaded
Warning: found an S4 version of 'as.array' so it has not been imported 

Yet, in a freshly initialized R console, I get:
 > methods("as.array")
[1] as.array.default
 > showMethods("as.array")

Function "as.array":
  <not a generic function>

Then, I load Matrix:

 > library(Matrix)
Loading required package: lattice

Attaching package: 'Matrix'

The following object(s) are masked from 'package:base':


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

Under ?methods the Note says

Functions can have both S3 and S4 methods, and function showMethods will 
list the S4 methods (possibly none).

Does the warning mean that I cannot (or should not) have an S3 as.array 
method in a package?
The method works in my context, but the warning will create problems 
when I submit to CRAN, so I would rather avoid it.

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-help mailing list