R Code for the Course Project