Skip to content
Prev 9441 / 15075 Next

R script in batch mode on Mac

On 07-11-2012, at 12:08, didier peeters wrote:

            
Try Rscript like this

for k in *.R; do
    Rscript -e "source('path/to/script.R')" $k
done

and get the name of the file to process from commandArgs()

or

Rscript -e "source('path/to/script.R')" *.xlsx

and loop over the elements of commandArgs() in the script.

or

use list.files() -- something like list.files(pattern="^.*\\.xlsx") -- in the script then you don't need to loop in the shell script.

Berend