[R-pkg-devel] Rcmd check and sourcing URL issues

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Tue Mar 16 19:17:10 CET 2021


On 16/03/2021 2:02 p.m., Andrew Simmons wrote:
> Hello,
> 
> 
> I am the maintainer of this.path
> <https://CRAN.R-project.org/package=this.path>, and as you can see
> from the CRAN
> checks <https://cran.r-project.org/web/checks/check_results_this.path.html>,
> it flags a NOTE that package testthat
> <https://CRAN.R-project.org/package=testthat> is undeclared in the R
> documentation references. this.path allows an R script to know its own path
> (from 'RStudio', 'RGui', the command-line, and when using 'source' or any
> source equivalents), and I recently added functionality to this.path when
> using testthat::source_file. However, I don't know how to go about
> declaring package testthat such that I can use it reference it in the R
> documentation WITHOUT forcing testthat to load or attach itself when
> this.path is loaded or attached (I don't want to declare testthat is the
> Imports or Depends field of the DESCRIPTION file).

Declaring it in Suggests sounds appropriate here.  Just make sure that 
your code works (perhaps with limited functionality) if testthat is not 
installed.  You do this by wrapping all uses in tests, e.g.

if (requireNamespace("testthat", quietly = TRUE)) {
    do something with testthat
} else
    do something else.


> 
> Another issue related to this.path and base::source, but the fix for this
> is more opinionated than the above. If someone sources a URL which contains
> a call to this.path, should this.path:
> * skip that source call and look for the next available path (which may or
> may not exist)
> * throw an error that this.path is incompatible when sourcing URLs
> * return the URL from that source call

No opinion.

Duncan Murdoch



More information about the R-package-devel mailing list