简体   繁体   English

R 包:递归安装依赖项

[英]R package: install dependencies recursively

I'm trying to install one of my R packages from Github using devtools (more precisely, install_github ).我正在尝试使用 devtools(更准确地说是install_github )从 Github 安装我的 R 包之一。 But, even if a I set the parameter dependencies to TRUE , dependencies are not being installed recursively.但是,即使我将参数dependencies设置为TRUE ,也不会递归安装依赖项。 That is, the dependencies of the dependencies are not being installed.也就是说,没有安装依赖项的依赖项。 Therefore, the package is not installed.因此,未安装该软件包。 R sends a message saying it could not find one of those dependencies. R 发送一条消息,说它找不到这些依赖项之一。 It keeps sending those messages until I install everything.它一直发送这些消息,直到我安装了所有东西。

Is it a standard behaviour?这是标准行为吗? Or am I missing something?或者我错过了什么? The package I'm talking about is this one: https://github.com/pedrocostaferreira/BETS .我正在谈论的包是这个: https : //github.com/pedrocostaferreira/BETS

I've never had this problem when installing other people's packages.我在安装其他人的软件包时从未遇到过这个问题。 Since my package has several imports and suggestions, it would be REALLY annoying for my users to install every dependency dependencies one by one, by hand.由于我的包有几个导入和建议,我的用户手动一个一个地安装每个依赖项真的很烦人。 What should I do?我该怎么办?

Snippet of the DESCRIPTION file:描述文件的片段:

Depends:
R (>= 3.2.0)
Imports: 
    testthat (>= 0.9.1),
    rootSolve, 
    ggplot2, 
    plotly, 
    urca, 
    TTR, 
    forecast, 
    TSA, 
    FinTS, 
    fpp, 
    stringi, 
    sqldf, 
    foreign, 
    lmtest, 
    normtest, 
    zoo, 
    rugarch,
    colorspace, 
    fracdiff, 
    tseries, 
    timeDate,
    htmlwidgets, 
    quadprog, 
    Rcpp, 
    gtable, 
    scales, 
    viridis
Suggests:
    grnn,
    Rsolnp,
    numDeriv,
    spd,
    ks,
    SkewHyperbolic,
    expm,
    DBI,
    RSQLite,
    gsubfn,
    tidyr,
    dygraphs,
    munsell,
    plyr,
    rmarkdown,
    nloptr,
    chron,
    gridExtra,
    xts

Large indeed, right?确实很大吧?

Some people suggested that if the package was already on CRAN, it wouldn't be happening.有人建议,如果该软件包已经在 CRAN 上,则不会发生。 Does it make sense?是否有意义?

The problem is there are inconsistency in DESCRIPTION and NAMESPACE .问题是DESCRIPTIONNAMESPACE不一致。 Many packages are imported in NAMESPACE , which required them to be in Imports or Depends fields of DESCRIPTION .许多包进口的NAMESPACE ,这需要他们在ImportsDepends的字段DESCRIPTION However they are listed under Suggests which means they are optional, so they are not installed automatically.但是,它们列在“ Suggests下,这意味着它们是可选的,因此不会自动安装。 But your package do need them installed before working.但是您的软件包在工作之前确实需要安装它们。

Method 1: move all packages to Imports in DESCRIPTION , then devtools should install them all.方法1:将所有包移动到DESCRIPTION Imports ,然后devtools应该安装它们。

Method 2: If you don't really need all of them for certain usage, and you don't want to install them all, do not import them in NAMESPACE .方法 2:如果您确实不需要所有这些用于某些用途,并且您不想全部安装它们,请不要在NAMESPACE导入它们。 Use full qualified name package::functionname instead.请改用全限定名称package::functionname

Read Namespace chapter of Hadley's book R package for more details阅读Hadley 的书 R 包的命名空间章节以获取更多详细信息

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

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