Finished R script