R/exec.R

Defines functions rscript

Documented in rscript

rscript <- function( package, script, arguments = commandArgs(TRUE), run = TRUE, dir = "exec" ){
	
	Rscript <- file.path( R.home(), "bin", "Rscript" )
	script  <- system.file( dir, script, package = package )
	if( !file.exists( script ) ){
		stop( sprintf( "script '%s' does not exist", script) )
	}
	
	arguments <- if( length( arguments ) == 0 ) "" else paste( arguments, collapse = " " )
	cmd <- sprintf( '"%s" "%s" %s', Rscript, script, arguments )
	
	if( run ){
		system( cmd )
	} else {
		cmd
	}
}

Try the exec package in your browser

Any scripts or data that you put into this service are public.

exec documentation built on May 31, 2017, 5:08 a.m.