R script for the assignment