
# Assign a value outside of the function
obj <- "Correct Value"

test <- function() {

  # assign a local value
  obj <- "incorrect value"

  # Print them out
  cat("\n",

      # using  `quote` inside `get`.  Note that get expects a string as first argument
      #!!  this does not work. It causes an error
        # get(quote(obj), envir=parent.frame()), "\n",
        
      #... but this does 
        get(as.character(quote(obj)), envir=parent.frame()), "\n",


      # all of the following evaluate

        # all of these return the correct value
        eval(quote(obj), envir=parent.frame()), "\n",
        eval(quote(obj), envir=sys.frame(-1)), "\n",
        get("obj", envir=parent.frame()), "\n",

        # This evaluates to the character string "obj"
        eval("obj", envir=parent.frame()) , "\n",

  

  "")
}; test()
