2
votes

I'm trying to install one of my R packages from Github using devtools (more precisely, install_github). But, even if a I set the parameter dependencies to TRUE, dependencies are not being installed recursively. 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. 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.

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. Does it make sense?

1
What package is this? - Rich Scriven
Dependencies are automatically resolved when you use the proper package installation functions such as install.packages() and a repository --- and you can always build a local repository, even on GitHub for free, via drat. - Dirk Eddelbuettel
@RichScriven it's this one: github.com/pedrocostaferreira/BETS. I'll include this info in the question. - Talitha Speranza
@DirkEddelbuettel I'm using devtools::install_github to install it. Still, isn't working - Talitha Speranza
did the small script in the readme work? - rawr

1 Answers

2
votes

The problem is there are inconsistency in DESCRIPTION and NAMESPACE. Many packages are imported in NAMESPACE, which required them to be in Imports or Depends fields of DESCRIPTION. However they are listed under Suggests which means they are optional, so they are not installed automatically. But your package do need them installed before working.

Method 1: move all packages to Imports in DESCRIPTION, then devtools should install them all.

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. Use full qualified name package::functionname instead.

Read Namespace chapter of Hadley's book R package for more details