modified the R file to complete RProgrammingAssignment2