R script for the course project