From edd at debian.org  Thu Sep  3 14:44:57 2009
From: edd at debian.org (Dirk Eddelbuettel)
Date: Thu, 3 Sep 2009 07:44:57 -0500
Subject: [Rd] How to ship R scripts with R packages ?
In-Reply-To: <4A9FACDE.3020505@dbmail.com>
References: <4A9E4F3D.5070704@dbmail.com> <4A9E5356.4020907@stats.uwo.ca>
	<4A9FACDE.3020505@dbmail.com>
Message-ID: <19103.47689.990868.212106@ron.nulle.part>


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.



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