code for R Programming - Programming Assignment 2