[Rd] Incorporate graphic files into R-package

Duncan Murdoch murdoch.duncan at gmail.com
Mon Sep 27 17:31:22 CEST 2010


  On 27/09/2010 10:44 AM, elgorgonzola wrote:
> Hi,
>
> I am working on a package which will be used to generate reports using
> Sweave. The createReport() function should create a folder and Rnw/tex-files
> automatically. The reports should, however, also feature the company logo. I
> don't want to have to manually copy the image file into the folder each time
> a report is created. I don't know if it is possible or not but I would like
> to somehow store the graphic-file within the package and have the
> createReport() automatically copy it to the appropriate folder. Does anyone
> have an idea how this could be achieved?
> I'm thinking of something similar to the way data is stored as a RData-file
> in the data-path of a package and is accessed via load() once the package is
> loaded.
>
> Thanks in advance and hava a great day.

Read about the "inst" directory in Writing R Extensions.  You can put 
your logo there, it will be installed when your package is installed, 
and your Sweave document can find it using system.file("path within 
package", package="yourpackage") to copy to the output directory.

Duncan Murdoch



More information about the R-devel mailing list