[Rd] relative path to source files in vignette

From: Peter Ruckdeschel <peter.ruckdeschel_at_web.de>
Date: Fri, 10 Oct 2008 20:19:25 +0200


this may be slightly off-topic, but as you are the experts:

we have written a small vignette, in which we want to refer to .R, .Rd source files by means of relative paths.

More specifically, we want to use TeX package "listings" to include source code,

[which btw in the mean time works pretty well together with "fancyvrb" so can be used
 with Sweave without problems...]

To avoid redundancy we would like to use


and to do so we somehow need path information.

This is /not/ a "listings" issue, as we might also have used

   \input{<r-source-file.R>}, only is \lstinputlisting a bit more flexible...

Using relative paths, i.e. as the vignette resides in subfolder "inst/doc" something like

     ../../../<mypkg>/R/<myR.R> or ../../../<mypkg>/man/<myRd.Rd>

does the job for both R CMD build and R CMD check , --- in standard configurations.

However, as you may change the location of the check folder with the -o option of R CMD check, (and possibly other things, we have not yet thought of ...), our solution is not quite satisfactory, so we have been wondering whether there is a (platform-independent) way to access the package source folder (under check) from within TeX.

We would appreciate an Sweave-chunk to do the following:
+have three arguments firstline, lastline, filename
  [where filename is relative to the package source folder]
+read out the information about the path to the package
  source folder [from the env-variable?]
+with this information read in the part of the source file
  between <firstline> and <lastline>
  and places this content ---without wrapping it to   \begin{Schunk} ... \end{Schunk}--- into the .tex file   ---preferrably already into a \begin{listing}\end{listing}    environment...

Any suggestions how to resolve this?

Thank you already,

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 10 Oct 2008 - 18:24: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 Fri 10 Oct 2008 - 19:30:20 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.

list of date sections of archive