r - stats::model.frame 中的错误...:在 geom_smooth 中指定权重时找不到对象
问题描述
示例代码如下(在统计上可能没有意义,但问题是object not found
)。而下一个作品:
mtcars %>% ggplot(aes(x = vs, y = mpg)) + geom_smooth(method="lm")
接下来不:
> mtcars %>% ggplot(aes(x = vs, y = mpg)) + geom_smooth(method=lm(weights = cyl))
Error in stats::model.frame(weights = cyl, drop.unused.levels = TRUE) :
object 'cyl' not found
为什么会出现这个错误?我能做些什么来解决它?
我也试过
> mtcars %>% ggplot(aes(x = vs, y = mpg)) + geom_smooth(method=lm(weights = "cyl"))
Error in terms.formula(formula, data = data) :
argument is not a valid model
和其他变体""
, 里面有更多信息lm
等,但没有成功。
非常感谢!
解决方案
mtcars %>% ggplot(aes(x = vs, y = mpg)) +
stat_smooth(method="lm", aes(weight= cyl))
这将生成一个图表,但我不确定它是否是您所追求的。这里可能与您想使用weight
的没有什么不同。weights
推荐阅读
- python-2.7 - 需要简单的示例代码来使用 pysimplegui 创建 ui
- google-cloud-platform - 对工件存储库的密钥环身份验证不起作用(GCP)
- sulu - Sulu:在管理员搜索中包含自定义实体
- python - 使用 Sphinx 生成文档时缺少类 make latexpdf
- wso2 - WSO2 ESB - 如何调用带有呼叫阻塞的迭代调解器?
- meshlab - 如何使用meshlab中的APSS功能进行去噪?
- neo4j - jQAssistant:无法重置外部 Neo4J 存储 - 为什么?
- python - pandas dataFrame 的替换给出了 NaN 值
- javascript - JS - 初学者 - 函数 isMaleName()
- android - 剃须刀付款给未找到适当的付款方式错误