R programming Assignment 2

This is my code for R programming course, assignment 2