Re: [Rd] relative path to source files in vignette [a solution somehow]

From: Peter Ruckdeschel <>
Date: Tue, 14 Oct 2008 18:03:57 +0200

Gabor Grothendieck schrieb:
> On Fri, Oct 10, 2008 at 7:06 PM, Peter Ruckdeschel
> <> wrote:
>> This could indeed be an option, but as noted in my reply to Robert, my
>> guess is that in the library where you install your packages to and which is
>> found with system.file(), you will no longer find the R source files but rather
>> some .rdb or .rdx file. At least this is what I found --- or is there some
>> magic trick to get back the source files from this?
> Yes, that is what occurs. That's why it was suggested to copy it.
Not sure whether this is helpful to anyone else out there, but here is my solution:

I could not find a satisfactory automatic solution %
(which should find the source folder[s] to my package[s]  automatically and correspondingly, in R should fill string  variables),
so I placed a README file into the inst/doc folder where I explain that to build / check / install my package[s] including the building of the vignette, one either has to call R CMD from the parent folder of the source folder to my package (distr) or one has to define path(s) in a file myPATH.

In the preamble of my .Rnw file, I put

% --- begin of code from newDistribution.Rnw in pkg distr --- % %
<<setPath, results=tex, echo=FALSE>>=

   cat("\\def\\distrPATH{",readLines("myPATH")[1],"}\n",sep="")    cat("\\def\\distrExPATH{",readLines("myPATH")[2],"}\n",sep="") }else{

   cat("\\def\\distrPATH{../../../distr}\n",sep="")    cat("\\def\\distrExPATH{../../../distrEx}\n",sep="") }

% define \lstinputlistingWithPath to be able to work with
% path information (parameter #2)
% so syntax for \lstinputlistingWithPath
%    \lstinputlistingWithPath[key=value-list]{<path>}{<file>}
% which then calls \lstinputlisting[key=value-list]{<path>/<file>}
%(but where <path> may be a macro which is expanded)



% --- end of code from newDistribution.Rnw in pkg distr --- %

and in the .Rnw file I use

\lstinputlistingWithPath[firstline=<nn>, lastline = <nn>]%




to include some man-file.
> Perhaps you should just preprocess your Sweave files prior to the build.
> The brew package could be used, for example.

I should have a look to it.

Thank you once again,
Peter mailing list Received on Tue 14 Oct 2008 - 16:06:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 14 Oct 2008 - 18:30:21 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive