Completed R code for class project - rprog004