R code and Plots