[R-pkg-devel] Replacing dplyr by stats functions
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. Best regards Adam Wysłane z aplikacji Poczta dla systemu Windows [[alternative HTML version deleted]] __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Replacing dplyr by stats functions
If you use Depends: in your package I think this is unavoidable (but, I don't think these should be counted against you as warnings by CRAN - they're "Warnings" not "WARNINGs" :-) ) The only way I know of to avoid this would be to Import: rather than Depend:, and import only the functions you need. On 2023-04-19 4:36 a.m., A. Kucharski 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. Best regards Adam Wysłane z aplikacji Poczta dla systemu Windows [[alternative HTML version deleted]] __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Replacing dplyr by stats functions
Hi Adam, If you don't mind adding another dependency to your package, you can use the {conflicted} package and its conflict_prefer function. Best, Ahmadou On Wed, Apr 19, 2023 at 2:18 PM A. Kucharski 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. > > Best regards > > Adam > > Wysłane z aplikacji Poczta dla systemu Windows > > > [[alternative HTML version deleted]] > > __ > R-package-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-package-devel -- Ahmadou H. DICKO, PhD Statistical consultant Mobile: (+221) 77 123 81 69 Skype: dicko.ahmadou.h Twitter : @dickoah Gitlab: gitlab/dickoa Github: github/dickoa __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Replacing dplyr by stats functions
On Wed, Apr 19, 2023 at 9:19 AM A. Kucharski 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@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-package-devel -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel