[R-pkg-devel] Examples taking too long depend on object that takes a while to generate

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Wed Sep 14 18:31:49 CEST 2022


On 14/09/2022 10:32 a.m., John Harrold wrote:
> Is there an example of how I can build it  at install time?

I don't know of one; the requirement of the architecture-specific 
version is very unusual.

But one general idea is that the .R files in the R directory are all 
executed at install time.  In a typical package that just creates 
functions, and they are saved in binary form in one of the files in the 
installed R directory.  But that code can do other things, such as 
creating a data object in the package environment, and maybe it can also 
write to package directories like the data directory before they get 
made read-only.

It's also possible to put .R files in the data directory, and they are 
executed to create the data object.  I think that happens at the time 
when you call data() rather than at install time, so it might not be 
helpful.  But I could be wrong.

Duncan Murdoch

> 
> On Wed, Sep 14, 2022 at 5:52 AM Duncan Murdoch <murdoch.duncan using gmail.com 
> <mailto:murdoch.duncan using gmail.com>> wrote:
> 
>     On 13/09/2022 11:21 p.m., John Harrold wrote:
>      > Hello,
>      >
>      > I'm working on submitting a new package. I've created examples
>     for each of
>      > the functions. Most of these functions depend on an R object that
>     uses
>      > architecture-specific compiled code. To create that object can
>     take between
>      > 10-20 seconds. The function that creates it will cache it in the
>     tempdir().
>      > So the first example that uses that object will take more than the 5
>      > seconds allowed by CRAN. If I wrap that example in donttest, then
>     the next
>      > function that uses it will exceed the 5 second limit, and on. I
>     submitted
>      > the package with all of these examples wrapped in donttest, but
>     that got me
>      > dinged :). So I'm trying to come up with a solution and I'd
>     appreciate any
>      > help here.
>      >
>      > Is there some way to build an object before tests are run?
> 
>     You could build it on your system, and save it in the data directory.
> 
>     If it really needs to depend on the current architecture, you could
>     build it at install time.
> 
>     Duncan Murdoch
> 
> -- 
> John
> :wq



More information about the R-package-devel mailing list