我是R的新手,并努力ggplot2工作.即使是在其他地方重现的简单代码片段也在我的机器上失败了.
这个:
library(ggplot2)
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point()
Run Code Online (Sandbox Code Playgroud)
给我:
y [setdiff(names(y),names(x))]中的错误:'closure'类型的对象不是子表
重要的是,这在昨天工作.我想不出任何改变的事情.现在不是.
我已重新安装R,Rstudio并ggplot2无济于事.我的猜测是某处存在版本问题,但我不确定.
谢谢你的帮助.
UPDATE
这是以下输出sessioninfo():
R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggrepel_0.5 scales_0.4.0 ggplot2_2.1.0
loaded via a namespace (and not attached):
[1] labeling_0.3 colorspace_1.2-6 plyr_1.8.3 tools_3.3.0
gtable_0.2.0
[6] Rcpp_0.12.5 grid_3.3.0 munsell_0.4.3
Run Code Online (Sandbox Code Playgroud)
如果设置了无效的默认主题,则可以重现此错误消息。例如:
library(ggplot2)
theme_set(theme_bw) # improper usage of theme_set, should be theme_set(theme_bw())
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point()
Run Code Online (Sandbox Code Playgroud)
给我错误
Error in y[setdiff(names(y), names(x))] :
object of type 'closure' is not subsettable
Run Code Online (Sandbox Code Playgroud)
但
library(ggplot2)
theme_set(theme_bw()) # have now fixed theme_bw
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point()
Run Code Online (Sandbox Code Playgroud)
工作正常。
| 归档时间: |
|
| 查看次数: |
830 次 |
| 最近记录: |