cleaned up Rscript logic, added helpful message on failure