updated R code

updated R code