我最近开始使用 R,并且对我的班级正在使用的 ggplot 感到困惑。我习惯了+运算符只添加两个输出,但我发现在 ggplot 中你可以执行以下操作:
ggplot(data = bechdel, aes(x = domgross_2013)) +
geom_histogram(bins = 10, color="purple", fill="white") +
labs(title = "Domestic Growth of Movies", x = " Domestic Growth")
Run Code Online (Sandbox Code Playgroud)
这里我们将两个函数调用添加在一起。这里到底发生了什么?ggplot 是否“重写”+运算符(也许就像如何重写==dart 中的运算符?)以便做一些不同的事情?或者“+”运算符在 R 中的含义与我在其他编程语言中习惯的含义不同?