programming assignment2 in R Done