我有一个关于如何在从源安装自制包时自动安装依赖库的问题。
基本上,DESCRIPTION
文件看起来像:
Package: mypackage
Type: Package
Title: mypackage_title
Version: 0.1.0
Author: test
Maintainer: test <test @example.com>
Description: More about what it does (maybe more than one line)
Depends:
dplyr,
stringr
License: MIT
LazyData: TRUE
RoxygenNote: 5.0.1
我跟着guide https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-Dependencies并创建了一个.tar.gz
文件。当我分发此软件包时,用户将从源安装。另外,我期望的是,从这个源码安装中,依赖库如dplyr
and stringr
如果这两个不可用,将自动安装。
我在虚拟机中进行了测试,但遇到了以下错误。那么对于这个问题有什么建议吗?提前致谢!
install.packages("path_to_my_tar.gz", repos=NULL, type="source")
Error: dependencies 'dplyr', 'stringr' are not available for package
更新:我尝试了其他几种方法但仍然失败......
方法一
install.packages("path/to/my/package", repos = NULL, type = "source")
ERROR: dependencies 'dplyr', 'stringr' are not available for package
方法二:放my package
, dplyr
, and stringr
into path/to/my/package/folder
install.packages("path/to/my/package", repos = "path/to/my/package/folder/", type = "source")
Warning in install.packages :
unable to access index for repository path/to/my/package/folder/src/contrib:
scheme not supported in URL 'path/to/my/package/folder/src/contrib/PACKAGES'
Warning in install.packages :
my packageis not available (for R version 3.3.1)
方法三:放my package
, dplyr
, and stringr
into path/to/my/package/folder
using contriburl
install.packages("path/to/my/package", contriburl = "path/to/my/package/folder/", type = "source")
Installing package into my package (as lib?is unspecified)
Warning in install.packages :
unable to access index for repository path/to/my/package/folder/:
scheme not supported in URL 'path/to/my/package/folder/PACKAGES'
Warning in install.packages :
my package is not available (for R version 3.3.1)
方法四:
install.packages("ProdComp08032016_0.1.2.tar.gz", repos = c("file://C:/Users/TH2/Downloads/", "http://cran.us.r-project.org http://cran.us.r-project.org”),类型=“来源”)
将软件包安装到 :/Users/TH2/Documents/R/win-library/3.3?(因为 ib? 未指定)
install.packages 中的警告:
无法打开压缩文件“//C:/Users/TH2/Downloads/src/contrib/PACKAGES”,可能的原因“没有这样的文件或目录”
install.packages 中出错:无法打开连接
方法5:
install.packages("ProdComp08032016_0.1.2.tar.gz", repos = c("C:/Users/TH2/Downloads/", "http://cran.us.r-project.org http://cran.us.r-project.org”),类型=“来源”)
将软件包安装到 :/Users/TH2/Documents/R/win-library/3.3?(因为 ib? 未指定)
install.packages 中的警告:
无法访问存储库 C:/Users/TH2/Downloads/src/contrib 的索引:
URL“C:/Users/TH2/Downloads/src/contrib/PACKAGES”不支持方案
install.packages 中的警告:
包rodComp08032016_0.1.2.tar.gz?不可用(适用于R版本3.3.1)