Skip to content

Instantly share code, notes, and snippets.

@robertzk
Last active December 30, 2015 12:48
Show Gist options
  • Save robertzk/7831115 to your computer and use it in GitHub Desktop.
Save robertzk/7831115 to your computer and use it in GitHub Desktop.
R exercise: Write your own version of get() using a function written in the style of where(). http://adv-r.had.co.nz/Environments.html
get <- function(name, env = parent.frame()) {
if (identical(env, emptyenv())) stop(name, ' not found')
if (exists(name, env = env, inherits = FALSE)) return(env[[name]])
else get(name, parent.env(env))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment