The +
usually throws non-numeric argument to binary operator
when provided with something other than a number. But it works with ggplot2, pasting the plot together. At the same time, it retains its usual function outside of the context of ggplot2 (e.g. as an arithmetic or formula operator), so its ggplot2 version is not in conflict with either of these.
I wish to understand how to make the +
behave this way. Browsing the ggplot2 github repo, I have found function definitions for +.gg
and %+%
but it did not make things clearer for me.
I would be happy with a pointer to the code in ggplot2 package that does this, or a generalized explanation of how this is done.
See Question&Answers more detail:os