[Rd] hook for configuring checking of \example{} sections of the documentation during R CMD check

Duncan Murdoch murdoch.duncan at gmail.com
Mon Jan 23 00:24:51 CET 2012

On 12-01-22 5:20 PM, Sylvain Loiseau wrote:
> Dear all,
> In a new package, I try to check the examples given in the \example section of the Rd files.
> However, the examples cannot be run if the package is not instructed, during startup time, in the place where some data are to be found ( with system.file("exampleData", "xyz", package="rcqp").
> Is there any hook available, or a place where some code might be added, so that it is executed before all the examples collected in Rd files are executed?

There are no special hooks for example files.

You could do this in a package load hook, though it might be more 
trouble than it's worth.  In your load hook, save the result of that 
call in a local variable.  Then reference that variable from your examples.

However, it's probably easiest just to put the line

exampleData <- system.file("exampleData", package="rcqp")

at the start of each example that needs it.

Duncan Murdoch

More information about the R-devel mailing list