我试图弄清楚为什么当我将数据传递给 ggplot 命令时 tee 运算符 %T>% 不起作用。
这工作正常
library(ggplot2)
library(dplyr)
library(magrittr)
mtcars %T>%
qplot(x = cyl, y = mpg, data = ., geom = "point") %>%
qplot(x = mpg, y = cyl, data = ., geom = "point")
这也很好用
mtcars %>%
{ggplot() + geom_point(aes(cyl, mpg)) ; . } %>%
ggplot() + geom_point(aes(mpg, cyl))
但是当我使用 tee 运算符时,如下所示,它会抛出“错误:ggplot2 不知道如何处理类原型环境的数据”。
mtcars %T>%
ggplot() + geom_point(aes(cyl, mpg)) %>%
ggplot() + geom_point(aes(mpg, cyl))
谁能解释为什么最后一段代码不起作用?