fix R code