Course Project 2 R codes