some R code for exercise