Part1 of programming assignment3 in R