R code to run course project, not completely finished