R code finalizing