This is hw 2 solution for R programming in coursera