[R-pkg-devel] How to reduce examples in a package that takes more than 5 seconds to run?

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Thu Dec 15 16:02:30 CET 2022



On 2022-12-15 9:57 a.m., Brian G. Peterson wrote:
> On 12/15/22 08:34, Ismail Otoakhia wrote:
>> The R package 'ardl.nardl' has some examples that take more than 5 
>> seconds
>> to run. I was advised by the CRAN team to reduce the run time to less 
>> than
>> 5 seconds.
>>
>> How can this be achieved?
> 
> - you can lower the amount of data in the example
> 
> - you can use a faster method than your default method
> 
> - you can wrap the example in a dontrun tag so it will not run during 
> checking
> 

   If your example involves something like a fitted model object that 
takes a long time to compute, you can pre-compute the model fit and 
store the object in an inst/testdata directory, then use something like

fitted_model <- readRDS(system.file("testdata", "my_example.rds", 
package = "mypackage"))

to retrieve it

> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics
 > E-mail is sent at my convenience; I don't expect replies outside of 
working hours.



More information about the R-package-devel mailing list