r - 将 method.args 添加到 ggplot stat_smooth() 会导致错误
问题描述
我正在尝试数据科学简介中的这个例子:使用 R 的数据分析和预测算法,第 28 章:
library(tidyverse)
library(dslabs)
data("polls_2008")
polls_2008 %>% ggplot(aes(day, margin)) +
geom_point() +
geom_smooth(span = 0.15, method.args = list(degree=1))
这会导致错误“警告消息:计算失败stat_smooth()
:'what' 必须是函数或字符串。” 删除method.args...
参数会导致正常操作。似乎将 method.args 定义为包括空列表在内的任何内容都会导致问题。
我正在使用为 Windows 和 ggplot2_3.3.2 构建的 R 版本 4.0.1 (2020-06-06)。谢谢你的帮助。
解决方案
我仔细检查过,这有效。他们将方法的默认值从“auto”更改为 NULL。这仍然与没有 method.arg 的“自动”使用相同。但我认为您需要告诉它您正在运行什么方法,以便它可以正确使用 method.args
polls_2008 %>%
ggplot(aes(day, margin)) +
geom_point() +
geom_smooth(method = "loess",
span = 0.15,
method.args = list(degree=1))
推荐阅读
- random - 具有随机睡眠间隔的罗技游戏软件宏
- python - CommandOnCooldown 错误处理程序未捕获错误!已经测试了一切
- google-cloud-platform - Google Cloud REST API 身份验证示例
- amazon-web-services - 在 AWS Lambda 上请求异步执行
- python - Scrapy和解释代码输出中get()和getall()的区别
- java - ExceptionHandler 在控制器中不起作用
- node.js - 创建实时通知系统的不同选项
- ansible - Ansible Jinja2 模板 - 捕获 textfsm 异常
- powershell - 哪个命令列出系统上的所有防火墙规则,输出包含信息和标头:规则名称、TCP 端口、已启用?
- c# - 使用 WinDbg 和 wpr 调试 OutOfMemory 异常。为什么这些符号显示为?!?- jited .net?