1

I am trying to push the following package to CRAN, but I keep getting an error on the check.

Error:

✓  checking R/sysdata.rda ...
    WARNING
   ‘qpdf’ is needed for checks on size reduction of PDFs
✓  checking installed files from ‘inst/doc’ ...
✓  checking files in ‘vignettes’ ...
E  checking examples (3s)
   Running examples in ‘oRus-Ex.R’ failed
   The error most likely occurred in:
   
   > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
   > ### Name: analyseStories
   > ### Title: Analysing Stories
   > ### Aliases: analyseStories
   > 
   > ### ** Examples
   > 
   > # Transform the stories
   > fileUrl <- example_stories()
   > stories <- analyseStories(fileUrl, 7)
   Joining, by = "word"
   Joining, by = "word"
   Error in loadNamespace(name) : there is no package called ‘reshape2’
   Calls: analyseStories ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
   Execution halted

Current problems:

  • The example is in orus::analyseStores(...) function.
  • The example actually runs and works on the pkgdown website.
  • The error appears only when doing devtools::check

I have tried multiple things:

I have run out of options. Any idea of what is happening?

Carrol
  • 1,225
  • 1
  • 16
  • 29
  • Why was it bounced by a person? – Axeman Jul 06 '20 at 21:31
  • Every user should be able to run the examples without error, but you are loading a package they might not have. You'd need a `dontrun`. – Axeman Jul 06 '20 at 21:34
  • @Axeman after the automated check, a person checks the package. And they bounced it back because I had used `\dontrun{...}` on the example that refuses to work. – Carrol Jul 06 '20 at 21:35
  • @Axeman The problem is I am not using any `reshape2` function directly. It is all due to transitive dependencies. If I put `reshape2` on the Imports in Description file, I get a warning that the package is not needed D: – Carrol Jul 06 '20 at 21:39
  • 2
    I'm a bit confused why you need to load `reshape2` for that example. – Axeman Jul 06 '20 at 21:39
  • 1
    It sounds to me that the example that you can't run is just a symptom, but not the root of the issue here. But rather, you have a deeper issue with dependencies not working as they should. – Axeman Jul 06 '20 at 21:42
  • 1
    Try adding `reshape2` to Suggests. I had similar issue today when using `sjlabelled::read_spss` in my package. When checking via ´devtools::check` both in my examples and my tests I got an error that `haven` is needed for this function. After adding `haven` to Suggests both the examples and the tests passed. – stefan Jul 06 '20 at 22:00
  • In relation to the \dontrun getting bounced back ; can you also add a `require` statement i.e. `\dontrun{ if (require("reshape2")) { your_example}}` . This is seen pretty regularly in help files. – user20650 Jul 06 '20 at 22:07
  • @stefan Ended up adding `reshape2` to suggests using `usethis::usepackage("reshape2", "Suggests")`. For now, CRAN check passes and I've submitted to CRAN. Hoping it doesn't get bounced back. Feel free to post it as an answer. – Carrol Jul 06 '20 at 22:08

1 Answers1

0

As @stefan suggested in the comments, I had to add reshape2 into the Suggested packages in the description file. I added using:

usethis::usepackage("reshape2", "Suggests")

Followed by regenerating the docs:

devtools:document()

Package is on its way to CRAN!

Carrol
  • 1,225
  • 1
  • 16
  • 29