ggfortify::autoplot 或 ggfortify:::autoplot 不工作

ggfortify::autoplot or ggfortify:::autoplot not working

以下代码工作正常:

library(ggfortify)
autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)

但是 ggfortify::autoplotggfortify:::autoplot 没有按预期工作。请参阅下面有错误的代码:

ggfortify::autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)

Error: 'autoplot' is not an exported object from 'namespace:ggfortify'

ggfortify:::autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)

Error in get(name, envir = asNamespace(pkg), inherits = FALSE) :
object 'autoplot' not found

想知道我在这里遗漏了什么。在此先感谢您的帮助。

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   

正如@hrbrmstr 在他的评论中指出的那样,调用自动绘图的正确方法是:

library(ggfortify)
ggplot2::autoplot(lm(Petal.Width ~ Petal.Length, data = iris), label.size = 3)

autoplot() 是调用 UseMethod("autoplot") 的 ggplot 函数。