added R code for graphs and tables