Bug 17171 - isS3method incorrectly returns FALSE for is.na.data.frame
Summary: isS3method incorrectly returns FALSE for is.na.data.frame
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 normal
Assignee: R-core
Depends on:
Reported: 2016-10-26 06:19 UTC by Richard Cotton
Modified: 2016-11-12 18:47 UTC (History)
1 user (show)

See Also:

suggested fix for isS3method (2.81 KB, text/plain)
2016-10-27 08:55 UTC, Richard Cotton

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Cotton 2016-10-26 06:19:09 UTC
To reproduce:

## [1] FALSE

This should return TRUE, since is.na.data.frame is the S3 method of is.na for data.frame objects, as seen by

## [1] is.na.POSIXlt         is.na.data.frame      is.na.numeric_version is.na.raster*        
## see '?methods' for accessing help and source code

and documented on the ?is.na help page.
Comment 1 Richard Cotton 2016-10-27 08:55:40 UTC
Created attachment 2174 [details]
suggested fix for isS3method

I've attached a possible fix for isS3method that loops over all choices of generic/class combinations.  For example, with "is.na.data.frame" as the input, it would check

fn = "is" and class = "na.data.frame"
fn = "is.na" and class = "data.frame"
fn = "is.na.data" and class = "frame"
Comment 2 Martin Maechler 2016-11-01 17:53:34 UTC
Thank you, Richie.

Your suggestion is good  "in spirit" but has too many changes compared to the source.  
My fix uses the (same ?) approach : look at all possible cases and return (TRUE) immediately if one case "works".

I may not get to commit my fix by tomorrow,
but there's no need for more proposals.
Comment 3 Martin Maechler 2016-11-12 18:47:52 UTC
Committed the fix    r71618 | maechler | 2016-11-03 12:48:47 +0100   (to R-devel)
and ported to 'R 3.3.2 patched'.