add R code and plot