【问题标题】:R scatterplot warning messages "is not a graphical parameter"R散点图警告消息“不是图形参数”
【发布时间】:2018-10-06 00:03:37
【问题描述】:

尝试在 R 中创建散点图时收到错误消息。我的教授在使用相同的数据集和相同的代码时没有收到此错误消息。我重新安装了 R、RStudio 和所有 R 包,但没有成功。情节看起来不错,所以我不明白为什么会抛出这些错误。

由于我正在使用 RMarkdown(不在此特定代码 sn-p 中,但我想将此图包含在 RMarkdown 文件中),错误消息与图表一起出现在 RMarkdown 输出中,我想删除这些输出中的错误消息,使其看起来很干净。

数据集取自https://wps.pearsoned.co.uk/wps/media/objects/12401/12699039/datasets3e/datasets/caschool.xlsx

我将不胜感激任何提示(1)抑制警告消息,因为情节实际上看起来不错(2)或解决潜在问题。当然,选项 (2) 会更好。

library(readxl)
caschool <- read_excel("../dataStockWatson15/caschool.xlsx")

library(car)
scatterplot(testscr~str, reg.line=FALSE, smooth=FALSE, spread=FALSE, boxplots=FALSE, span=0.5, ellipse=FALSE, levels=c(.5, .9), data=caschool)
warnings()

警告:

Warning messages:
1: In plot.window(...) : "reg.line" is not a graphical parameter
2: In plot.window(...) : "spread" is not a graphical parameter
3: In plot.window(...) : "span" is not a graphical parameter
4: In plot.window(...) : "levels" is not a graphical parameter
5: In plot.xy(xy, type, ...) : "reg.line" is not a graphical parameter
6: In plot.xy(xy, type, ...) : "spread" is not a graphical parameter
7: In plot.xy(xy, type, ...) : "span" is not a graphical parameter
8: In plot.xy(xy, type, ...) : "levels" is not a graphical parameter
9: In axis(side = side, at = at, labels = labels, ...) :
  "reg.line" is not a graphical parameter
10: In axis(side = side, at = at, labels = labels, ...) :
  "spread" is not a graphical parameter
11: In axis(side = side, at = at, labels = labels, ...) :
  "span" is not a graphical parameter
12: In axis(side = side, at = at, labels = labels, ...) :
  "levels" is not a graphical parameter
13: In axis(side = side, at = at, labels = labels, ...) :
  "reg.line" is not a graphical parameter
14: In axis(side = side, at = at, labels = labels, ...) :
  "spread" is not a graphical parameter
15: In axis(side = side, at = at, labels = labels, ...) :
  "span" is not a graphical parameter
16: In axis(side = side, at = at, labels = labels, ...) :
  "levels" is not a graphical parameter
17: In box(...) : "reg.line" is not a graphical parameter
18: In box(...) : "spread" is not a graphical parameter
19: In box(...) : "span" is not a graphical parameter
20: In box(...) : "levels" is not a graphical parameter
21: In title(...) : "reg.line" is not a graphical parameter
22: In title(...) : "spread" is not a graphical parameter
23: In title(...) : "span" is not a graphical parameter
24: In title(...) : "levels" is not a graphical parameter
There were 48 warnings (use warnings() to see them)

【问题讨论】:

    标签: r plot r-markdown


    【解决方案1】:

    这些警告似乎是在最新版本的汽车包中创建的,我猜你正在运行该包。至少,在将包从版本 2.1.6 更新到版本 3.0.0 并添加包 openxlsx_4.0.17 和 rio_0.5.10 之后,我可以复制警告。

    没有简单地忽略警告,因此您的解决方案似乎是安装汽车软件包版本 2.1.6。你可以在这里下载源代码:https://cran.r-project.org/src/contrib/Archive/car/

    有关如何编译本地包然后加载它的说明,请参见以下说明:http://cmdlinetips.com/2012/05/how-to-install-a-r-package-locally-and-load-it-easily/

    【讨论】:

    • 您的解决方案有效,错误消息消失了!感谢你的付出。是的,我正在运行最新版本的汽车软件包。不幸的是,降级到汽车版本 2.1.6 导致另一个错误。我也在使用 RcmdrMisc 包,这个包需要汽车版本 3.0.0 或更高版本。你知道如何关闭警告信息吗?我认为这可能是快速解决问题的唯一选择。我不能不使用 RcmdrMisc。
    • 此处描述了全局关闭警告:stackoverflow.com/questions/16194212/…
    • 顺便说一下,如果你在 knitr 中使用scatterplot() 命令,可以通过包含块选项warning=FALSE 将警告消息重定向到控制台,请参阅yihui.name/knitr/options
    猜你喜欢
    • 1970-01-01
    • 2019-05-10
    • 2022-08-20
    • 2017-09-06
    • 2021-09-04
    • 2012-02-06
    • 1970-01-01
    • 2022-01-18
    • 2019-02-08
    相关资源
    最近更新 更多