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

From: Peter Ruckdeschel <peter.ruckdeschel_at_web.de>
Date: Sat, 11 Oct 2008 01:06:17 +0200

Thanks again Gabor, for your quick reply,
> Try placing a copy of the files in the inst directory and then
> accessing them via system.files("myfile.R", package = "mypackage")
>
you mean I should do this in an S-chunk in the .Rnw file? I.e., running Sweave on it would then produce the copy into my Sweave file I need?

This could indeed be an opition, 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?

> or place them in the same directory as the Sweave file
> and then access them without a directory path at all:
> readLines("myfile.R")
>
If I put the sources statically into the same directory as the Sweave file (i.e. in [...]/myRsources/myPkg/inst/doc), of course everything works fine;

The issue is that I want to "dynamically" include parts of the source R code itself (without unnecessary static copying the source R code due to consistency traps, when changing the R code but not the copy) from the R directory of the package into the Sweave file by something like          

  \input{[Path]/myRfile.R}

so that once I change the R code, I do not have to change the .Rnw file.

[I do not include the whole .R file but only certain lines of it, of course]

As already said, in a standard configuration something like \input{../../../myPkg/R/myRfile.R}

   % goes from [...]/myRSources/myPkg/inst/src to [...]/myRSources/myPkg/R
   % in R CMD build
   % resp. from [...]/myRSources/myPkg.Rcheck/inst/src to
[...]/myRSources/myPkg/R

   % in R CMD check
does the job.

Now if I am in [...]/myRSources and say something like

R CMD build myPkg ### still works
R CMD check myPkg -o /yetAnotherPath/myCheck

   ## does not work as /yetAnotherPath/myPkg/R need not be [...]/myPkg/R

So what I was looking for was something like defining an environment variable
$myRSources (in a platform-independent way) which may be accessed (in a platform-independent way) from the TeX command \input{...} --- perhaps with something like

\input{$myRSources/myPkg/R/myRfile.R}

but I cannot figure out how to do this...

Thank you once again
Peter



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 10 Oct 2008 - 23:08:44 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 Sat 11 Oct 2008 - 15:30:19 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