1

I was developing a package when I found a new error when building the package.The error makes reference to a line that previously didn't have any problem and I didn't modify. However it run smoothly in a fresh R session when I ran the code or knit the vignette alone.

Long story short: I found that this error happens when a suggested package (by my package's DESCRIPTION) is loaded before my package.

How can I control this?

The reason of the error is that my package (A) has a function is named exactly the same as the other package (B) because it does the same kind of process, but I use a different name for the same arguments (and in my version I provide other arguments as well). A solution I found is to use A::function, but that would be uglier to the reader. Is there any other solution?

This didn't happened in previous cycles of development. I have observed it on the latest R version R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree" and in the devel version of R. The packages are build using both R CMD build package and devtools::check() The conflicting package is in Suggests: part of the DESCRIPTION file of the package

This question might be related to this other one.

llrs
  • 3,308
  • 35
  • 68
  • I just happen to be working on my first R package just now. So curious about this comment from you: "A solution I found is to use A::function, but that would be uglier to the reader." Do you mean everytime to call your function, user would have to use `A::your_function()` ? BTW, I think this is the only way out when two packages are loaded together and have same name functions, you have to use the `::` trick. – tushaR Feb 27 '18 at 06:38
  • 1
    @TUSHAr yes, but that didn't happen in previous releases/builds of the package. @ Downvoters, care to explain? I'll edit with more information, but I can't paste a package in a SO question... – llrs Feb 27 '18 at 06:46
  • Please check if this helps: https://stackoverflow.com/questions/8637993/better-explanation-of-when-to-use-imports-depends – tushaR Feb 27 '18 at 06:59
  • @TUSHAr no, I'll edit but i have the other package in suggests as it is not needed for my package – llrs Feb 27 '18 at 07:12
  • 1
    Why don't you rename your function? Yes, it does the same thing as the one in the other package, but giving it a unique name might help users later on in distinguishing the functions, i.e. `nlme::nlme` vs. `lme4::nlmer`. – nya Feb 27 '18 at 08:01
  • @nya Because I should then rename several other functions of the package. The idea is to make aware the users that they are using this kind of action from my package and not from the other package. Yes, I could rename them, but it has been released as is for a year, and I can't change the API that way in a single release by the repository guidelines (it is in Bioconductor) – llrs Feb 27 '18 at 08:22
  • 1
    Other than the function name change and what @TUSHAr suggested with `::` or removing the suggested package as it is not needed for your package (perhaps explain this in another section of the DESCRIPTION file?), I have no answers. But, please, let us know how you eventually solve the issue. – nya Feb 27 '18 at 11:26

0 Answers0