简体   繁体   English

如何从自定义存储库强制安装 R 包?

[英]How do I force installation of R package from custom repo?

There's a dependency of dependency which fails to compile when pulled from CRAN at the moment, so the maintainer provided an alternative Cannot compile RcppArmadillo .目前从 CRAN 中提取时,存在无法编译的依赖项,因此维护者提供了替代方法无法编译 RcppArmadillo

I've tried to install RcppArmadillo from that path like so:我尝试从该路径安装RcppArmadillo ,如下所示:

if(!require("RcppArmadillo")) install.packages("RcppArmadillo", repos="https://rcppcore.github.io/drat", lib = LIB_PATH)
library(RcppArmadillo)

if(!require("sqjin/scAI")) devtools::install_github("sqjin/scAI", lib = LIB_PATH)
library(scAI, lib.loc = LIB_PATH)

However, I can see in the logs that RcppArmadillo is still being pulled from CRAN .但是,我可以在日志中看到RcppArmadillo仍在从CRAN中提取。

How do I force the installation from custom repo?如何从自定义存储库强制安装?

By setting your options("repos") (named vector) argument in one of your (user or system) startup files you make the alternate location known to R. After that R will pick the highest (== "newest") version (number).通过在您的(用户或系统)启动文件之一中设置options("repos") (命名向量)参数,您可以让 R知道备用位置。之后 R 将选择最高(==“最新”)版本(数字)。

Here is a block from help(Startup) showing one way to do it:这是help(Startup)一个块,显示了一种方法:

 ## Example of Rprofile.site
 local({
   # add MASS to the default packages, set a CRAN mirror
   old <- getOption("defaultPackages"); r <- getOption("repos")
   r["CRAN"] <- "http://my.local.cran"
   options(defaultPackages = c(old, "MASS"), repos = r)
   ## (for Unix terminal users) set the width from COLUMNS if set
   cols <- Sys.getenv("COLUMNS")
   if(nzchar(cols)) options(width = as.integer(cols))
   # interactive sessions get a fortune cookie (needs fortunes package)
   if (interactive())
     fortunes::fortune()
 })

where you could just use你可以在哪里使用

   r["CRAN"] <- "https://cloud.r-project.org"
   r["Rcpp"] <- "https://RcppCore.github.io/drat"

As the RcppCore repo is a drat repo you could also consult the drat documentation which has other examples and helpers.由于RcppCore回购是一个drat回购你也可以咨询drat它有其他的例子和助手文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM