R/exec.R

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 2, 2019, 6:51 p.m.