R script edited for the assignment.