R code changes for graphs