Sometimes it is useful to run a R script under slightly different settings,
such as different data set name. However it does not seem possible to pass
additional options to R CMD BATCH. Here is a shell script
(download runR.sh) to get around it:
#! /bin/sh if [ $# -lt 1 ]; then echo "Usage: `basename $0` Rscript.R [ arguments ]" exit 2 fi RCMD="R --vanilla -q" RSCRIPT=$1 if [ ! -f $RSCRIPT ]; then echo "R script '$RSCRIPT' does not exist" exit 3 fi shift echo "source (\"${RSCRIPT}\", echo = TRUE)" | ${RCMD} --args $@
To use it, run
runR.sh Rscript.R [ arguments ]
Rscript.R needs to deal with the arguments with something like:
argv <- commandArgs () nignore <- which (argv == "--args") argv <- argv[-(1:nignore)] print (argv) if (length (argv) == 0) { stop ("Need one argument") }
The R installer packaged provided on CRAN uses X11 Tcl/Tk. I like to compile
R from source to use the Aqua version of Tcl/Tk. According to
R Mac OS X FAQ: Tcl/Tk Issues, one needs do the following in the Resources/bin
directory of the R.framework.
sudo /Developer/Tools/Rez -t APPL Carbon.r -o R.bin
svm
function in R package e1071 is based) and SVM-Light.