【发布时间】:2019-10-11 13:28:22
【问题描述】:
我正在尝试将黄土平滑添加到我使用 geom_line(stat='count') 创建的 ggplot 中的分组线图中。
这是一个类似的问题,但答案不适用于分组变量: Combining stat_bin with stat_smooth
p = ggplot(mtcars, aes(x=cyl, colour=factor(vs))) +
geom_line(stat = 'count')
dat <- layer_data(p)
p + stat_smooth(data = dat, aes(x, y))
我想要每个组的平滑线。使用上面的代码我得到错误:因子错误(vs):找不到对象'vs'
【问题讨论】: