Coursera r programming - Programming Assignment 3