R 自动安装所有包依赖项

R 自动安装所有包依赖项,r,R,因此,我在github上安装了一个R包x library(devtools) install_github("bla/bla") 安装失败(请参阅下面的错误打印输出)。包x有一些依赖项,包括ggplot2。x的所有依赖项都会自动安装,包括ggplot2,但未安装包scales,即ggplot2的依赖项。因此,它失败了。因此,依赖项的依赖项不会自动安装 在我的描述文件中,我对ggplot2使用“Depends”。我注意到在ggplot2描述文件中,scales位于“导入”下,而不是“依赖”下 我

因此,我在github上安装了一个R包
x

library(devtools)
install_github("bla/bla")
安装失败(请参阅下面的错误打印输出)。包
x
有一些依赖项,包括
ggplot2
x
的所有依赖项都会自动安装,包括ggplot2,但未安装包
scales
,即ggplot2的依赖项。因此,它失败了。因此,依赖项的依赖项不会自动安装

在我的描述文件中,我对ggplot2使用“Depends”。我注意到在ggplot2描述文件中,
scales
位于“导入”下,而不是“依赖”下

我知道只要手动安装
scales
,或者手动安装依赖项,我就可以解决所有这些问题。但是,有没有办法自动安装所有依赖项?”“依赖”和“进口”?还是我遗漏了什么

请参阅下面的控制台打印输出:

Installing 1 package: Cairo
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/Cairo_1.5-9.zip'
Content type 'application/zip' length 1026234 bytes (1002 KB)
downloaded 1002 KB

package ‘Cairo’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\rmf\AppData\Local\Temp\Rtmp8Eaf5a\downloaded_packages

package ‘ggplot2’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\rmf\AppData\Local\Temp\Rtmp8Eaf5a\downloaded_packages
Installing 1 package: gridExtra
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/gridExtra_2.2.1.zip'
Content type 'application/zip' length 483300 bytes (471 KB)
downloaded 471 KB

package ‘gridExtra’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\rmf\AppData\Local\Temp\Rtmp8Eaf5a\downloaded_packages
Installing 1 package: gtable
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/gtable_0.2.0.zip'
Content type 'application/zip' length 57807 bytes (56 KB)
downloaded 56 KB

package ‘gtable’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\rmf\AppData\Local\Temp\Rtmp8Eaf5a\downloaded_packages
Installing 1 package: tidyr
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/tidyr_0.6.1.zip'
Content type 'application/zip' length 860798 bytes (840 KB)
downloaded 840 KB

package ‘tidyr’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\rmf\AppData\Local\Temp\Rtmp8Eaf5a\downloaded_packages
"C:/R/R-33~1.3/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  "C:/Users/rmf/AppData/Local/Temp/Rtmp8Eaf5a/devtools2fe8287648ea/royfrancis-test-4d3547f" --library="C:/R/R-3.3.3/library"  \
  --install-tests 

* installing *source* package 'x' ...
** R
** inst
** tests
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called 'scales'
Error : package 'ggplot2' could not be loaded
ERROR: lazy loading failed for package 'x'
* removing 'C:/R/R-3.3.3/library/x'
Error: Command failed (1)
会话信息

R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] devtools_1.12.0

loaded via a namespace (and not attached):
[1] httr_1.2.1    R6_2.2.0      tools_3.3.3   withr_1.0.2   curl_2.5      memoise_1.0.0
[7] git2r_0.18.0  digest_0.6.12

你只是做错了。包存储库(如在CRAN中,或使用drat或其他一种repo创建工具完成)具有依赖性。随机GitHub代码repo不会。在这种情况下,我要做的是创建一个包,然后将其放入包存储库中。我想使用CRAN中的
install.packages()
或devtools中的
install\u github()
进行安装,这两种安装依赖性都是因为描述文件中的内容。我要澄清的是,我的x包不仅仅是随机的R代码,它有一个合适的R包结构,所以理论上它应该像普通的R包一样安装。我要澄清的是:它不是你的包,而是你安装它的地方。仅仅希望GitHub代码存储库实际上是一个R包存储库并不能实现这一点。您需要创建一个包存储库。这是很琐碎的,也是我写drat来帮忙的原因。这可能与: