R codes and plots for assignment #1