The completed R codes and plots for project 1