R code for reporting