R Code for Project