[R-pkg-devel] S3 generic/method consistency false positive when dplyr imported

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Wed Jan 4 22:22:09 CET 2023


On Wed, 4 Jan 2023 15:54:52 -0500
"Aaron A. King" <kingaa using umich.edu> wrote:

> Why does inclusion of *dplyr* in the import list appear to trigger
> these warnings when they were not there before?

I think that's because dplyr itself contains an S3 generic named
"filter", and having a package namespace loaded (not even attached) is
enough to take its registered S3 methods into consideration for method
dispatch. Here we have an opposite situation, though, and your
functions aren't registered as S3 methods. Will your function still be
called if you artificially construct a wrong object and feed it to
dplyr::filter while your package namespace is attached?

library(YOURPACKAGE)
dplyr::filter(structure(list(), class = 'traj'))

Additionally, stats::filter doesn't seem to be an S3 generic, so that's
one thing that the check gets confused about.

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list