Skip to content

Undocumented S4 method Warning For Bracket

2 messages · Dario Strbenac, Martin Morgan

#
Hello,

With R version 3.0.2 Patched (2013-10-30 r64123) I don't see warnings that I get in R Under development (unstable) (2013-11-03 r64145)

The warnings are like :

Undocumented S4 methods:
  generic '[' and siglist 'BayMethList,ANY,ANY'

The function actually looks like :

setMethod("[", "BayMethList",
    function(x, i) {
  # Code to subset object.
}

It has 2 parameters, not 3. The warning also happens in R 3.0.2 Release. Has this been fixed in Patched but not in the development version ?

--------------------------------------
Dario Strbenac
PhD Student
University of Sydney
Camperdown NSW 2050
Australia
5 days later
#
On 12/05/2013 07:00 PM, Dario Strbenac wrote:
Not a complete answer but actually the generic is

 > getGeneric("[")
standardGeneric for "[" defined from package "base"

function (x, i, j, ..., drop = TRUE)
standardGeneric("[", .Primitive("["))
<bytecode: 0x46a54e0>
<environment: 0x4698330>
Methods may be defined for arguments: x, i, j, drop
Use  showMethods("[")  for currently available ones.

and the fact that you've implemented a simpler method signature doesn't change 
the overall signature

 > getMethod("[", "BayMethList")
Method Definition:

function (x, i, j, ..., drop = TRUE)
{
     .local <- function (x, i)
     {
     }
     .local(x, i, ...)
}

Signatures:
         x
target  "BayMethList"
defined "BayMethList"

Notice how your method actually accepts and then silently ignores a 'j' 
argument. A better (?) method definition would be

    setMethod("[", c("BayMethList", "ANY", "missing"),
        function(x, i, j, ..., drop=TRUE) {})

so a user providing a 'j' argument would be told that there was no matching method.

Martin