Completed assignment for R programming.