definitive R code