R code for visualizations in final project