Adding R code snippets I learned from Coursera lesson