R Script for Exam 2/Question 3