From murdoch.duncan at gmail.com  Mon Jan 23 00:24:51 2012
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Sun, 22 Jan 2012 18:24:51 -0500
Subject: [Rd] hook for configuring checking of \example{} sections of
 the documentation during R CMD check
In-Reply-To: <90332261-F32C-422C-8FCA-67FBCC526ECF@univ-paris13.fr>
References: <90332261-F32C-422C-8FCA-67FBCC526ECF@univ-paris13.fr>
Message-ID: <4F1C9AC3.90603@gmail.com>

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



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