以下代码工作正常:
library(ggfortify)
autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)但是,ggfortify::autoplot和ggfortify:::autoplot并不像预期的那样工作。见下面有错误的代码:
ggfortify::autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)错误:“自动绘图”不是从“命名空间:ggfortify”导出的对象
ggfortify:::autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)在get(name,envir = asNamespace(pkg),inherits = FALSE)中出错: 对象“自动绘图”未找到
不知道我在这里错过了什么。提前感谢您的帮助。
sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: i686-pc-linux-gnu (32-bit)
Running under: Ubuntu 16.04.1 LTS
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggfortify_0.3.0.9000 ggplot2_2.2.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.8 tidyr_0.6.0 dplyr_0.5.0 assertthat_0.1 grid_3.3.2
[6] plyr_1.8.4 R6_2.2.0 gtable_0.2.0 DBI_0.5-1 magrittr_1.5
[11] scales_0.4.1 lazyeval_0.2.0 labeling_0.3 tools_3.3.2 munsell_0.4.3
[16] colorspace_1.3-1 gridExtra_2.2.1 tibble_1.2 发布于 2017-08-16 11:18:49
正如@hrbrmstr在他的评论中指出的那样,调用autoplot的正确方式是:
library(ggfortify)
ggplot2::autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)autoplot()是一个调用UseMethod("autoplot")的ggplot函数。
https://stackoverflow.com/questions/41060391
复制相似问题