Get Network Representation of an R Package

Tools from the domain of graph theory can be used to quantify the complexity and vulnerability to failure of a software package. That is the guiding philosophy of this package. 'pkgnet' provides tools to analyze the dependencies between functions in an R package and between its imported packages.

CRAN_Status_Badge CRAN_Download_Badge Build Status codecov


pkgnet is an R library designed for the analysis of R libraries! The goal of the package is to build a graph representation of a package and its dependencies to inform a variety of activities, including:

  • prioritizing functions to unit test based on their centrality
  • examining the recursive dependencies you are taking on by using a given package
  • exploring the structure of a new package provided by a coworker or downloaded from the internet

Table of contents

  1. How it Works
  2. Installation
  3. Usage Examples
  4. How to Contribute
  5. Next Steps

How it Works

The core functionality of this package is the CreatePackageReport function.


This package is now available from CRAN!


Usage Examples

Try it out!

result <- CreatePackageReport('ggplot2')

How to Contribute

To report bugs, request features, or ask questions about the structure of the code, please open an issue.

If you'd like to contribute to the project, please open a pull request. PRs should follow the project's contribution guidelines.

Next Steps

This is a fairly new project and, as the version number indicates, should be regarded as a work in progress.


pkgnet 0.3.2




  • Added unit tests for network measure calculations (#166).
  • Revised unit test setup and teardown files to enable devtools::test() to work as well as CRAN server testing (#167)


  • Corrected node statisitcs table merging error (#165, #166)
  • Added a NAMESPACE entry for knitr to suppress warning on CRAN server checks (#168)

pkgnet 0.3.1




  • Unit testing strategy on CRAN vs Travis and local. See #160 for details.



pkgnet 0.3.0


  • InheritanceReporter, a reporter for R6, Reference, and S4 class inheritance relationships within a package. (#14, #129)
  • Dropdown menu in graph visualizations for selecting which node to highlight. (#132, #143)


  • Edge direction reversed to align with UML dependency diagram convention. Now, if A depends on B, then A->B. (#131, #143)
  • Reporters now support all layouts available in igraph. Use grep("^layout_\\S", getNamespaceExports("igraph"), value = TRUE) to see valid options. (#143)
  • FunctionReporter now utilizes graphopt layout by default. (#143)
  • FunctionReporter now supports non-exported functions and R6 class methods. (#123, #128)
  • Orphaned node clustering was removed in favor of using layout to better handle graphs with many orphaned nodes. (#102, #143)
  • Testing strategy with subpackages are now CRAN and TRAVIS compatible. (#121, #139, #144)
  • Test package milne created for unit testing of InheritanceReporter and R6 method support in FunctionReporter. (#128, #129)
  • Width of html reports now adjust to size of screen. (#143)
  • Default node colors are now colorblind accessible. (#130, #141)
  • Additional various improvements to UX for package reports. (#143)


  • Rendering of the table in Function Network tab. (#136, #138)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.4.0 by Brian Burns, 18 days ago,

Report a bug at

Browse source code at

Authors: Brian Burns [aut, cre] , James Lamb [aut] , Patrick Boueri [ctb] , Jay Qi [aut]

Documentation:   PDF Manual  

BSD_3_clause + file LICENSE license

Imports assertthat, covr, data.table, DT, futile.logger, glue, igraph, knitr, magrittr, methods, R6, rlang, rmarkdown, tools, visNetwork

Suggests devtools, testthat, withr

Suggested by RWsearch, getTBinR.

See at CRAN