R code for Lab3 and Quiz3