【发布时间】:2021-11-19 19:19:51
【问题描述】:
我正在尝试在我的图表上添加线条以显示 mean + sd,但我不断收到相同的错误代码:
“平均值错误(NoHealthInsurance):对象'NoHealthInsurance'不是 找到”。
我的括号是不是放错地方了?
hist <- ggplot(data = west) +
geom_histogram(aes(NoHealthInsurance),
color = wes_palette("Zissou1", 1),
fill = wes_palette("Zissou1", 2)[2]) +
geom_vline(xintercept = (mean(NoHealthInsurance))) +
geom_vline(xintercept = (mean(NoHealthInsurance) - sd(NoHealthInsurance)), color = "blue") +
geom_vline(xintercept = (mean(NoHealthInsurance) + sd(NoHealthInsurance)), color = "blue") +
geom_vline(xintercept = (mean(NoHealthInsurance) - 2*sd(NoHealthInsurance)), color = "red", linetype = "dotted") +
geom_vline(xintercept = (mean(NoHealthInsurance) + 2*sd(NoHealthInsurance)), color = "red", linetype = "dotted")
【问题讨论】:
-
如果您创建一个小的可重现示例以及预期的输出,这将更容易提供帮助。阅读how to give a reproducible example。
标签: r dplyr error-handling