Added original R script for reference