[R-pkg-devel] Replacing dplyr by stats functions
Joshua Ulrich
jo@h@m@u|r|ch @end|ng |rom gm@||@com
Wed Apr 19 16:51:51 CEST 2023
On Wed, Apr 19, 2023 at 9:19 AM A. Kucharski <aqcharski using interia.pl> wrote:
>
> Hi,
>
> I am developing my own package. I have a problem with its new version. Checking on the CRAN server gives 2 warnings like this (critpath is my package):
> Warning: replacing previous import 'dplyr::lag' by 'stats::lag' when loading 'critpath'
> Warning: replacing previous import 'dplyr::filter' by 'stats::filter' when loading 'critpath'
>
> On my machine these warnings show up during Check but before Build starts so at the end I get a message that the number of warnings is 0. I don't use lag or filter at all in my package although I use both of these packages. Reordering the dplyr and stats package names in the Depends of the Description file didn't help. Is it a problem with my code or a conflict between those two packages? Please help me remove these warnings.
>
It's a conflict between stats and dplyr. The dplyr lag() function
masks the base R stats lag() generic, which breaks S3 method dispatch
for every package that has a lag() method when dplyr is attached.
You should use Imports instead of Depends unless you need the package
attached, which is a rare case.
The latest version of critpath on CRAN uses `import()` in the
NAMESPACE file. That imports every function in the entire package. Use
`importFrom()` to import only the functions you use from the package.
That should help avoid these types of conflicts.
> Best regards
>
> Adam
>
> Wysłane z aplikacji Poczta dla systemu Windows
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
More information about the R-package-devel
mailing list