我正在学习有关 R 的 Udacity 类(class),其中一个练习让我编写此代码以绘制散点图并覆盖“平均”线和三个“四分位数”线。
ggplot(aes(x = age, y = friend_count), data = pf) +
xlim(13, 90) +
geom_point(alpha = 0.05, position = position_jitter(h = 0), color = 'orange') +
coord_trans(y = 'sqrt') +
geom_line(stat = 'summary', fun.y = mean) +
geom_line(stat = 'summary', fun.y = quantile, fun.args = list(probs = 0.1), color = 'blue', linetype = 2) +
geom_line(stat = 'summary', fun.y = quantile, fun.args = list(probs = 0.5), color = 'blue', linetype = 2) +
geom_line(stat = 'summary', fun.y = quantile, fun.args = list(probs = 0.9), color = 'blue', linetype = 2)
我想查看
fun
的文档geom_line
内部的参数,所以我查看了 geom_line
的文档(在 R Studio 和在线),以及 geom_line
函数显示为geom_line(mapping = NULL, data = NULL, stat = "identity", position = "identity",
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...)
我没有看到
fun
参数随处。所以我的问题是:如果我还没有了解 fun
Udacity 类(class)中的参数,我如何通过查看文档了解它,以及如何获取有关它的更多信息?
最佳答案
短版:
在 ?stat_summary
我们找到了 fun.y
争论。
如何到达:
先查参数 在 ?geom_line
.在那里我们找到了“省略号参数”...
:
...
other arguments passed on tolayer
.
然后点击链接到
?layer
:Usually layers are created using
geom_*
orstat_*
在您的情况下,您使用了包装器
geom_line
(而不是 layer(geom = "line",
)与 stat = "summary"
一起.后者因此引导我们到 stat_summary
.最后,在
?stat_summary
我们找到了 fun.y
争论。
关于r - 在哪里可以找到关于 `fun` 中的 `geom_line` 参数的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42303922/