On 12/15/22 9:02 AM, Ben Bolker wrote:


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


The "sos" package includes a function "CRAN", which is used for that purpose. The examples section in "findfn.Rd" includes the following:


# Skip these tests on CRAN,
# because they take more than 5 seconds
if(!CRAN()){
...
}


I know that some on this list do not like this construct, but it has helped me manage this problem for several years. NOTE: This CRAN function is NOT maintained by anyone on CRAN, so it is NOT guaranteed to work. However, the "sos" package is currently on CRAN, and I have not seen an email asking me to avoid it ;-)


https://github.com/sbgraves237/sos/blob/master/man/findFn.Rd


          Hope this helps.
          Spencer Graves

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


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

Reply via email to