R Script for Exercise 2 of Assignment 2