R code and plots

R code and plots.