[R-pkg-devel] Usage of internet resources in examples

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Tue Oct 20 22:45:27 CEST 2020


   Depending on what you want to do,

   if (interactive())

or

   try()  (in the examples, not in the function)

or

   if (testthat::skip_on_cran())

all seem like reasonable solutions.



On 10/20/20 4:28 PM, Andy Teucher wrote:
> Our package bcdata (https://cran.r-project.org/package=bcdata) retrieves public data from British Columbia data services, so the examples are dependent on successfully hitting web resources. When we initially submitted to CRAN the examples were wrapped in \dontrun{}, but we were asked to change them to use \donttest{}.
> 
>   
> Now, CRAN is running checks with _R_CHECK_DONTTEST_EXAMPLES_=true, and one of the examples has failed due to a changed web resource. I got an email asking me to fix it and reminding me of the CRAN policy:
>   
> 
>    'Packages which use Internet resources should fail gracefully with an informative message
> 
>   if the resource is not available or has changed (and not give a check warning nor error).'
> 
>    This needs correction whether or not the resource recovers.
> 
>   
> I would prefer that in normal use, the function calling the internet resources fails with an error so that the user is properly alerted. I also agree that these failures shouldn't cause a check error. To demonstrate the use of these functions in examples, is there a preferred method of ensuring that failures will not cause a check warning or error? Should I try to revert back to using \dontrun{} and plead my case? Wrap in `if interactive())`?
>   
> 
> Thanks very much,
> 
> Andy Teucher
> 
>   
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>



More information about the R-package-devel mailing list