


test[, printEnv(environment()) ]


# This doesnt work; neither with nor without the env in the function
    getCols <- function(colNames)  {
      lapply(colNames, function(x)  {get(x, envir=parent.frame(3))}  )    
    }

    print(test[, getCols(columnsUsing) ])

# Same. This doesnt work; neither with nor without the env in the function
    getCols <- function(colNames, env)  {
      ret <- list()
      for (cname in colNames)
         ret <- c(ret, get(cname, envir=env)) 
      return(ret)   
    }

    print(test[, {env <- environment(); getCols(columnsUsing, env)}])


# But this works
    print(test[, lapply(columnsUsing, function(x) get(x, envir=parent.frame(2))  )] )

#  Trying out different values for i 
    for (i in 1:5)  {
      cat("i is", i, nl)
      print(test[, lapply(columnsUsing, function(x)  get(x, envir=parent.frame(i)))  ])
      print(test[, getCols(columnsUsing)])
    }


# Sample env function
printEnv <- function(env)
  {cat("Env is: "); print(env)}
