Bug 16194 - selectMethod() fails to find the method under certain conditions
Summary: selectMethod() fails to find the method under certain conditions
Status: ASSIGNED
Alias: None
Product: R
Classification: Unclassified
Component: S4methods (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-02-07 00:58 UTC by Hervé Pagès
Modified: 2015-06-16 13:18 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hervé Pagès 2015-02-07 00:58:19 UTC
Hi,

Assuming it's not unreasonable to expect that selectMethod() reflects what the "real dispatch mechanism" does, the former should be able to find what the latter has no problem finding. Unfortunately, this is not always the case. Here is an example:

  > setGeneric("foo", function(x, y) standardGeneric("foo"))
  [1] "foo"

  > setMethod("foo", c("ANY", "ANY"), function(x, y) "YES")
  [1] "foo"

  > foo(1:4, letters)
  [1] "YES"

  > selectMethod("foo", c("integer", "character"))
  Error in selectMethod("foo", c("integer", "character")) : 
    no method found for signature integer, character

This is a long standing bug that has been a source of frustration and confusion for many Bioconductor users for years (they've a hard time figuring out what method was actually called, which they need to know before they can access its man page).

Thanks,
H.
Comment 1 John Chambers 2015-02-07 17:38:39 UTC
Confirmed.

But to make the report more useful for purposes of debugging, it appears to require two more conditions:
1- the signature must have 2 (or more?) arguments.
2- no non-default method has been defined for 2 arguments.

At least, either of the two variations on the example show no error:

- as provided, but selectMethod("foo", "integer")
- before calling selectMethod as in the example, set some actual 2-argument method: setMethod("foo", c("raw","raw"), function(x,y) "raw")
(a method for x only doesn't do)