Hello,

WRE contains the following information about the "exec" subdirectory of 
a package :

"Subdirectory exec could contain additional executables the package 
needs, typically scripts for interpreters such as the shell, Perl, or 
Tcl. This mechanism is currently used only by a very few packages, and 
still experimental."

I think it would be useful to expand "very few". For example "tcltk" 
uses it.

But the real questions are;
- can this be used in conjunction with "R CMD", something like

$ R CMD execute package script parameters

The alternative used in a few packages (Rserve, Roxygen, ...) is to add 
a file in ${R_HOME}/bin, but I am not sure this works with binary builds 
of packages

- can the script be an R script, in that case would a shebang like this 
be enough :

#!/bin/env Rscript

definitely works on (at least my) linux

A very naive "execute" written in R follows.

Romain




#!/bin/env Rscript

args <- commandArgs(TRUE)
if( length(args) < 2 ){
         stop( "usage : R CMD execute package script [parameters]\n" )
}

package <- args[1]
script <- args[2]
scriptfile <- file.path( system.file( "exec", script, package = package ) )
if( !file.exists( scriptfile ) ){
         stop( sprintf( "file not found: '%s' ", scriptfile  ) )
}

trail <- if( length(args) > 2 ) paste( tail( args, -2 ), sep = " " ) else ""
cmd <- sprintf( '"%s" %s', scriptfile, trail )
system( cmd )



-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/vsK1 : R parser package on CRAN
|- http://tr.im/vshK : Transfer files through Rserve
`- http://tr.im/vfxe : R GUI page on the R wiki



        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to