updates to R programming problem 2