我在尝试在 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()
Run Code Online (Sandbox Code Playgroud)
警告:
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)
Run Code Online (Sandbox Code Playgroud)
这些警告似乎是在最新版本的汽车软件包中创建的,我认为您正在运行该软件包。至少,在将软件包从版本 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-ar-package-locally-and-load-it -容易地/