R code for example.