I often use R CMD BATCH to run my files (e.g. script.R), and get the
output recorded in script.Rout -- this is great.  On my setup (R.2.3.0
on linux), if any plots are created, they get stored in Rplots.ps.
This can get confusing if I have several batch scripts in one
directory.

I've written a simple shell script to rename Rplots.ps to
e.g. script.Rout.ps so that later I can easily identify which script
created the original postscript file.  Just thought I'd share it in
case others were interested, or had comments.

Stephen
----------------------------------------------------------------------
#!/bin/sh
## Run R in BATCH mode.

## Usage:
## rb infile

## First (and only argument) is the R script to run in batch.
in=${1}

## Check that the input file exists.
if [ -r ${in} ]
then
    ## I do not like .RData to be saved
    R CMD BATCH --no-save ${in}
else
    echo "File ${in} does not exist."
    exit -1
fi

## if Rplots.ps is readable, rename it to X.Rout.ps
if [ -r Rplots.ps ]
then
    outps=`basename ${in} .R`.Rout.ps
    mv Rplots.ps ${outps}    
fi

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to