plots and R code added