Completed R code for - Lexical Scoping