Programming Assignment 2 for coursera rprog-006