Search code examples
rversion-controldependenciespackage

Listing R Package Dependencies Without Installing Packages


Is there a simple way to get a list of R package dependencies (all recursive dependencies) for a given package, without installing the package and it's dependencies? Something similar to a fake install in portupgrade or apt.


Solution

  • You can use the result of the available.packages function. For example, to see what ggplot2 depends on :

    pack <- available.packages()
    pack["ggplot2","Depends"]
    

    Which gives :

    [1] "R (>= 2.14), stats, methods"
    

    Note that depending on what you want to achieve, you may need to check the Imports field, too.