Coursera r programming course assignment 3