plot.default
不接受数据参数,所以你最好的选择是通过管道with
:
mynei %>%
select(Emissions, year) %>%
group_by(year) %>%
summarise (total=sum(Emissions))%>%
with(plot(year, total))
如果有人错过了 @aosmith 对这个问题的评论,plot.formula
does有一个数据参数,但是当然formula
是第一个参数,所以我们需要使用.
将数据放在正确的位置。所以另一个选择是
... %>%
plot(total ~ year, data = .)
当然,ggplot
takes data
作为第一个参数,所以使用ggplot
do:
... %>%
ggplot(aes(x = year, y = total)) + geom_point()
lattice::xyplot
is likeplot.formula
:有一个数据参数,但它不是第一个,所以:
... %>%
xyplot(total ~ year, data = .)
只需查看文档并确保您使用.
if data
不是第一个论点。如果没有的话data
根本没有争论,使用with
是一个很好的解决方法。