Added functional R code.