This is the fourth programming assignment in R programming