R coursera assignment 2