Last active
November 29, 2017 20:19
-
-
Save brodieG/0793724c2bc782a95244a4657a88a7c9 to your computer and use it in GitHub Desktop.
Turn Ggplot into a Pipe Operated Machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| `%>%` <- function(lhs, rhs) UseMethod("%>%") | |
| `%>%.default` <- magrittr::`%>%` | |
| `%>%.gg` <- function(lhs, rhs) ggplot2:::`+.gg`(lhs, rhs) | |
| # WARNING: IF YOU DO THE FOLLOWING YOU SHOULD PROBABLY EXIT AND | |
| # RESTART YOUR R SESSION SO THAT MAGRITTR IS RESTORED TO ITS | |
| # ORIGINAL STATE. | |
| assignInNamespace("is_pipe", | |
| function (pipe) | |
| { | |
| identical(pipe, quote(`%>%`)) || identical(pipe, quote(`%T>%`)) || | |
| identical(pipe, quote(`%<>%`)) || identical(pipe, quote(`%$%`)) || | |
| identical(pipe, quote(`%>%.default`)) | |
| }, | |
| "magrittr" | |
| ) | |
| iris %>% ggplot() %>% geom_point(aes(x=Sepal.Width, y=Sepal.Length, color=Species)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment