15

I continue to get the following R CMD check (via devtools::check()) for a package I am preparing to submit to CRAN (you can see the results for the package here:

Check: dependencies in R code 
Result: NOTE 
    Namespace in Imports field not imported from: ‘tidyr’
     All declared Imports should be used. 

The source code for the package is here on GitHub. I've removed any mention of tidyr or its functions throughout the package, but the note remains. There are a number of Stack Overflow questions (i.e., this and other resources on this, but none seem to apply to this situation. How can I address this note?

Joshua Rosenberg
  • 4,014
  • 9
  • 34
  • 73
  • 4
    Look a little harder at your `DESCRIPTION` file. – Dirk Eddelbuettel Jan 28 '18 at 15:16
  • Ugh, still don't see it! – Joshua Rosenberg Jan 28 '18 at 15:26
  • Are you testing the _repository_ or the _tarball_ ? I can't tell---I have uploaded packages to CRAN for 15+ years without these additional obfuscation tools. Worked for me, but hey, it's a big tent. – Dirk Eddelbuettel Jan 28 '18 at 16:25
  • Ie a simple GH search of your repo reveals tidyr being used in a script you have .Rbuildignore'd ... Last I checked computers were still deterministic so why don't you try with and without that file? – Dirk Eddelbuettel Jan 28 '18 at 16:27
  • Hm, I removed that script as well as any mention of it in `.Rbuildignore` and ran again... still get the same note. Also searched the repo for tidyr and nothing comes up. – Joshua Rosenberg Jan 28 '18 at 16:46
  • 2
    As I said, for the last fifteen years I have relied on `R CMD ...` tools (and simple wrappers/aliases I wrote) which works for me. Maybe try that instead of `devtools`. Or maybe it is something else. But R sees it used _somewhere_. – Dirk Eddelbuettel Jan 28 '18 at 16:48
  • Yes but - this came up when we submitted to CRAN (we didn't notice until we got back an automated response), so it has something to do with... R CMD check (I think). – Joshua Rosenberg Jan 28 '18 at 16:49
  • It's your package, mate. Simplify it til it passes, or else don't upload it. – Dirk Eddelbuettel Jan 28 '18 at 16:50
  • You could of course also turn it upside down. declare defeat and just give in, add it it `Import:` and `import()` and move on. It seemingly is a side-effect of the other packages you, and as those are are not part of my common workflow I cannot say much else. – Dirk Eddelbuettel Jan 28 '18 at 16:57
  • 2
    Something doesn't add up. The "CRAN Package Check Results" are for the *current version* of the package *on CRAN*. That version (0.1.0) includes "Imports: tidyr" in the DESCRIPTION file, which causes the NOTE. But I don't see how that's relevant to your question. The package you uploaded (version 0.2.0) doesn't include "Imports: tidyr" in the DESCRIPTION file, so it wouldn't generate a NOTE. So the actual issue is completely unclear. – Joshua Ulrich Jan 28 '18 at 17:16
  • @JoshuaRosenberg is there are finally an answer to this question? I found this question while getting 'an unfortunate note' on some of the R Flavors on CRAN: https://cran.rstudio.com//web/checks/check_results_lazytrade.html. 5 out of 12 flavors are giving a Note... should I pay attention to that? – vlad1490 Jul 28 '19 at 18:56
  • I'm really sorry @vlad1490, I actually don't recall exactly what caused this - or fixed it. I'm tempted to close it. – Joshua Rosenberg Jul 30 '19 at 19:58
  • I think that I am able to solve this by adding package name in front of each function. So stupid but it is enough to add that reference just once in one function then note will not popup anymore... I was also using pipes from magrittr package, these errors could be bypassed by adding it to Suggests field of the Description file... @JoshuaRosenberg – vlad1490 Aug 09 '20 at 13:06
  • 1
    Are you (1) specifying the namespace when calling external functions from other packages, (2) adding those package to `Imports` in `DESCRIPTION`, and (3) adding `import()` statements in `NAMESPACE` for the external functions in question? I noticed that `R CMD CHECK ...` produced that note, but `devtools::check()` did not. In my case, the note was not produced when the `--as-cran` flag was used, which is what `devtools::check()` does by default (e.g., `cran = TRUE`). The (1), (2), and especially (3) above helped me get rid of it. – Mihai Oct 01 '21 at 11:12

1 Answers1

2

This message appears when you include a package in the Imports: field in DESCRIPTION file and no function in this namespace is called by any function of the package. In this case, it means that in the R code of the package there was no call like tydir::fun, where fun represents any function of that package.

To solve it, simply delete the reference to the package in Imports: field within DESCRIPTION file. This was fixed in this commit for the package involved in the question: clustRcompaR.

If you don't want the message to appear when you check the package using devtools:check(), set option CRAN = FALSE: devtools::check(CRAN = FALSE)

tic-toc-choc
  • 815
  • 11
  • 26
josep maria porrà
  • 1,198
  • 10
  • 18