just providing my solution to the issue that occurs when submitting a package to CRAN and getting an error similar to this:
* checking tests ... [838s/167s] NOTE
Running ‘testthat.R’ [838s/167s]
Running R code in ‘testthat.R’ had CPU time 5 times elapsed time
Now I couldn't replicate this error (locally, on win-hub or rhub) and found very little information on this.
I found a few helpful discussions on the R-pkg-devel mailing list: The result of the R-core discussions here or a question for another package that had the same issue here with the solution on GitHub here.
Essentially the issue is related to the number of CPU cores used by a package - and the CRAN policy to try to avoid a package using too many by default.
The solution involves setting the variable OMP_THREAD_LIMIT
to 2
. For this, I created a new file called packagename.R
that looked like this:
.onLoad <- function(libname, pkgname) {
# CRAN OMP THREAD LIMIT
Sys.setenv("OMP_THREAD_LIMIT" = 2)
}
And this did the trick when submitting it to CRAN next time around. Hopefully this is useful to others as well!