assignment2 in R programming