rscript version of the R script