R code added for analysis