Added R code for comparison