Skip to content
Prev 38623 / 63424 Next

warning creating an as.array method in a package

I found a solution to this problem, but don't understand why it was 
necessary. In a clean workspace, I get:

 > methods(as.array)
[1] as.array.default
 > showMethods("as.array")

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

So, I just added the generic definition to my package, making with 
warnings go away.

as.array <- function(x, ...)
	UseMethod("as.array")

as.array.loddsratio <- function (x, log=x$log, ...)
	drop(array(coef(x, log = log), dim = dim(x), dimnames=dimnames(x)))

Yet, help(as.array) says:

as.array is a generic function for coercing to arrays. The default 
method does so by attaching a dim attribute to it. It also attaches 
dimnames if x has names.   Is this a documentation error?

 > sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_2.11.1
 >
On 12/9/2010 10:05 AM, Michael Friendly wrote: