R codes and plots for Assignment 1