Homework Assignment 2 for R course at Coursera