From murdoch at stats.uwo.ca  Wed Sep  2 13:13:26 2009
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Wed, 02 Sep 2009 07:13:26 -0400
Subject: [Rd] How to ship R scripts with R packages ?
In-Reply-To: <4A9E4F3D.5070704@dbmail.com>
References: <4A9E4F3D.5070704@dbmail.com>
Message-ID: <4A9E5356.4020907@stats.uwo.ca>

Romain Francois wrote:
> Hello,
>
> (This is a remix of this previous thread: 
> https://stat.ethz.ch/pipermail/r-devel/2009-August/054264.html , but 
> with a concrete example)
>
> I am developing some packages that contain scripts (for Rscript) and 
> would like to know what is the best/recommended way to ship these scripts.
>
> An example is the "ant" package (R capable version of apache ant, see 
> http://tr.im/xHLs). The package has a ant.R script in the exec directory 
> and here is how I use it :
>
> $ `Rscript -e "cat( system.file( 'exec', 'ant.R', package = 'ant' ) ) " `
>
> ... not so pretty. Meanwhile, "Writing R extensions" talks about the 
> exec directory, but it is not clear if I can use it this way or how.
>
>   

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


> Romain
>
>



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