R scatterplot警告消息“不是图形参数”

时间:2018-04-25 13:20:35

标签: r plot r-markdown

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

由于我正在使用RMarkdown(不在此特定代码段中,但我想将此图包含在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)

1 个答案:

答案 0 :(得分: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/