adding R codes and plots