fixed error in R code