R code for undergrad statistics course