Assignment2 of R programming course