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

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

Gabor Grothendieck schrieb:
> On Fri, Oct 10, 2008 at 7:06 PM, Peter Ruckdeschel
> <peter.ruckdeschel_at_web.de> wrote:
>
[snip]
>> 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>>=
if(file.exists("myPATH")){

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)
%%%%%%%%%%%%%%%%%%%%%%%%%%%


%
\makeatletter
\def\lstinputlistingWithPath{\@ifnextchar[%

{\@lstinputlistingWithPath}{\@lstinputlistingWithPath[]}}

\def\@lstinputlistingWithPath[#1]#2#3{%
\def\@doLIstInput{\lstinputlisting[#1]}
\expandafter\@doLIstInput\expandafter{#2/#3}

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



and in the .Rnw file I use

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

{\distrPATH}{R/<filename-of-myRsource>.R}

resp.

\lstinputlistingWithPath{\distrPATH}%
{man/<filename-of-myRsource>.Rd}

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

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel 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 https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.