[R] install.packages and dependencies=TRUE

Gábor Csárdi csardi.gabor at gmail.com
Tue Dec 17 17:38:41 CET 2013


Thanks!

Btw, install() from the devtools package can do this in theory, but
not in practice, because of a bug (it silently ignores "Suggests").
This is fixed in their github version.

Just to add something useful here.

Gabor

On Tue, Dec 17, 2013 at 11:36 AM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 17/12/2013 11:26 AM, Gábor Csárdi wrote:
>>
>> Dear all,
>>
>> I am trying to install a private package, with its dependencies. However,
>> both
>>
>> install.packages("sand_1.0.tar.gz", dependencies=TRUE, repos=NULL,
>> type="source")
>>
>> and
>>
>> install.packages("sand_1.0.tar.gz", dependencies="Suggests",
>> repos=NULL, type="source")
>>
>> fail to install suggested packages:
>>
>> > packageDescription("sand")$Suggests
>> [1] "network, sna, ape, ergm, mixer, vioplot, ROCR, fdrtool, huge"
>>
>> Based on the docs, I got the (obviously wrong) impression, that it was
>> possible to install suggested packages. From ?install.packages,
>> dependencies argument:
>>
>>            ‘TRUE’ means to use ‘c("Depends", "Imports", "LinkingTo",
>>            "Suggests")’ for ‘pkgs’ and ‘c("Depends", "Imports",
>>            "LinkingTo")’ for added dependencies: this installs all the
>>            packages needed to run ‘pkgs’, their examples, tests and
>>            vignettes (if the package author specified them correctly).
>>
>> > library(ergm)
>> Error in library(ergm) : there is no package called ‘ergm’
>> > library(huge)
>> Error in library(huge) : there is no package called ‘huge’
>>
>> What am I doing wrong, and more importantly, what is the correct way
>> to install _all_ dependencies of a package?
>
>
> The problem is with repos=NULL (i.e. a local install).  Since none of those
> dependencies are local, they aren't found and won't be installed.
>
> I imagine some package has a function that does what you want, but I don't
> know it.  It wouldn't be hard to put one together as follows:
>
> 1.  install your package without its dependencies.
> 2.  use tools::package_dependencies() to find the (non-recursive)
> dependencies.
> 3.  install those, with their dependencies.
>
> You could add a step to filter the list in 2 so that you don't re-install
> something that is already there.
>
> Duncan Murdoch



More information about the R-help mailing list