added last R code