R program for the course project