I am trying to understand why the tee operator,% T>%, does not work when I pass data to the ggplot command.
It works great
library(ggplot2) library(dplyr) library(magrittr) mtcars %T>% qplot(x = cyl, y = mpg, data = ., geom = "point") %>% qplot(x = mpg, y = cyl, data = ., geom = "point")
And it also works great
mtcars %>% {ggplot() + geom_point(aes(cyl, mpg)) ; . } %>% ggplot() + geom_point(aes(mpg, cyl))
But when I use the tee operator, as shown below, it throws "Error: ggplot2 does not know how to handle the class proton environment data."
mtcars %T>% ggplot() + geom_point(aes(cyl, mpg)) %>% ggplot() + geom_point(aes(mpg, cyl))
Can someone explain why this last piece of code is not working?
r ggplot2 magrittr
Tim cameron
source share