R code for plot 1