我发现自己经常想命名一个情节并显示它。所以我可能会做类似的事情
require(ggplot2)
myplot <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) + geom_point() # store the plot
myplot # view the plot
有没有一种更优雅的方式可以在一行中显示和查看绘图?myplot <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) + geom_point(); myplot
比我的意思更优雅。
有时我也会这样做:
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) + geom_point()
myplot <- last_plot()
但这并没有更好。