Base R has a function
get() that searches for a given name over the environment stack and returns its value after finding it. For example, we can use it like this.
If you don’t understand why they returned the values they did, you can learn how
environment works by reading this post.
We can write our own version of get() using recursion. First we write a helper function that works the same as
get(name, inherits = T).
Next we can easily extend it to a more general version that takes an additional parameter
Moreover, we can easily extend
get_helper() to a function
fget_helper() that finds only function objects.