added R code and saved plots