[Rd] How to ship R scripts with R packages ?

Dirk Eddelbuettel edd at debian.org
Thu Sep 3 14:44:57 CEST 2009


On 3 September 2009 at 13:47, Romain Francois wrote:
| On 09/02/2009 01:13 PM, Duncan Murdoch wrote:
| > I think exec is a reasonable place to put the script. If you don't want
| > to type that long command above, why not put it in a small function in
| > the package? E.g. define
| >
| > antR <- function() cat( system.file( 'exec', 'ant.R', package = 'ant' ) )
| >
| > then you can run it with
| >
| > Rscript -e "ant::antR()"
| >
| > Duncan Murdoch
| 
| I've implemented a minimal version of this in package "exec". For example.
| 
| $ Rscript -e "exec::rscript( 'ant', 'ant.R')"
| 
| Romain
| 
| btw, exec is maintained at r-forge :
| 
| $ svn checkout svn://svn.r-forge.r-project.org/svnroot/highlight/pkg/exec

Interesting. I should take a look. I had similar needs for Rcpp as R doesn't
provide a 'pkg-config'-alike function for add-on packages.  Rcpp provides a
header and a library for its users. These need to be found by the user's
Makefiles, so following a suggestion Simon once made, what we now do is to
provide

  Rcpp:::CxxFlags()
  Rcpp:::LdFlags()

which aren't even in the NAMESPACE file and meant to be called directly from
configure scripts or Makefiles as in (using either little

  $ r -e'Rcpp:::CxxFlags()'
  -I/usr/lib/R/site-library/Rcpp/libedd at ron:~$

  $ Rscript -e 'Rcpp:::LdFlags()'
  -L/usr/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/lib/R/site-library/Rcpp/lib$

(and notice the lack of a trailing 'backslash-n').

Could there be scope for generalising this up into R proper for 2.11 or
later?

Dirk

-- 
Three out of two people have difficulties with fractions.



More information about the R-devel mailing list