more fixes to R code