R file updated with the solution to Programming Assignmnent 2