A lot of the help page examples for quo take forms like this one, assigning an output of quo to quo:
quo <- quo(letters)
quo <- quo(toupper(!! quo))
quo
eval_tidy(quo)
It seems clear that these assignments do not overwrite the quo function (since he does it twice in a row) as they normally would. First-rate objects, and all that.
So my best guess of what is going on is that this is not a normal assignment, but rather the assignment form of quo, quo<-. But I have not been able to any information on this.
Unproductive:
getAnywhere(quo<-)
getAnywhere(`quo<-`)
getAnywhere(`quo <-`)
rlang:::quo<-
rlang:::`quo<-`
rlang:::`quo <-`
So I'd like someone who can tell me what the assignment form is for and how it works, and even more so if what I am seeing is not the assignment form, butt rather some aspect of the rather gnomic "[q]uo self-evaluates in its own environment."
Finally, if there is accessible documentation of this function or usage somewhere, I'd like to know how I could have found it, and if not, I should probably tell Hadley. How he keeps so many plates spinning without dropping more balls than he does is a complete mystery to me.
You've just attached
rlang
, your search path now looks like:If you do this interactively at the command line, this should happen in
.GlobalEnv
:Now
quo
orget("quo")
start the search forquo
in.GlobalEnv
, find it there (the quosure you've just created) and stop:If you want to find the function, you have to bypass
.GlobalEnv
and start the search in its enclosing environment,package:rlang
. You're in luck, this is where it resides:(Oh, this
namespace:rlang
you see is not where we've foundquo
, but its enclosing environment, viz. where it's going to start its own search when it's called. See the map of the world: source: Suraj Gupta http://blog.obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/)If you already know you're looking for a function, you can use the handy
fget
inpryr
that overlooks everything that is not a function:(Note:
match.fun
can also come in handy when you're writing your own function).Or you can just let R be smart, and directly use parens, R will know it has to look for a function, this is what is done in:
(Also compare:
The error messages hint at what R can't find/looks for, with and without parens.)
Now for fun, let's attach the whole tidyverse:
Search path just got a lot messier:
If we're curious and want to know where
quo
is found, we can usewhere
frompryr
. Again, we should bypass.GlobalEnv
and start in its enclosing environment,package:forcats
, for instance:Surprise,
quo
is now found inpackage:dplyr
rather thanpackage:rlang
. This is becausepackage:dplyr
comes before in the search path, and as it happens, it re-exportsquo
fromrlang
to make it directly available indplyr
.