[R] R scripts

Al Piszcz apiszcz at solarrain.com
Thu Aug 21 13:04:18 CEST 2003


I have two examples
here first is real basic answers your question, second
handles arguments. I am interested in getting a more
robust command line parser for R, perhaps using PERL GetOpt::Long
as a front end is the quickest solution.



#1 (answers your question)
===

$ more Rb
#!/bin/sh
R --quiet \
  --no-save \
  < $*


#2 adds arguments
===
$ more Rba
#!/bin/sh
##
## ARG 1 is the R program to RUN
## rest of line are arguments

if [ $# -eq 0 ] ; then
  echo
  echo "usage: Rba RPROGRAM.r ARG1 ARG2 ...."
  echo
  exit
fi


program=$1
shift
cmdargs=$*

gtime R --quiet \
  --no-save \
  $cmdargs < $program




More information about the R-help mailing list