R Code for the project