working on R code