[Rd] Undocumented S4 method Warning For Bracket
Martin Morgan
mtmorgan at fhcrc.org
Wed Dec 11 11:39:52 CET 2013
On 12/05/2013 07:00 PM, Dario Strbenac wrote:
> 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 ?
>
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
> --------------------------------------
> Dario Strbenac
> PhD Student
> University of Sydney
> Camperdown NSW 2050
> Australia
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
More information about the R-devel
mailing list