added R codes and plots