R Script for the assignment