Examine and analyse static function call graphs of R packages. Mostly derived from functionality provided by the r-lib/pkgapi package, which is not on CRAN and must first be installed with

remotes::install_github ("r-lib/pkgapi")

Currently contains a single function, pg_graph(), which returns all exported and non-exported functions from a package (as nodes), and tallies of all functional connections between these (as edges). The function also includes a plot parameter which can be used to visualize the resultant network using the visNetwork package.

git2r::clone ("https://github.com/ropensci/git2r", local_path = "./git2r")
# Currently needs absolute file paths to work
pkg_dir <- tools::file_path_as_absolute ("./git2r")
g <- pg_graph (pkg_dir, plot = FALSE)

prior art

  • Much of the functionality is primarily built upon the pkgapi package.
  • The flow package produces flow diagrams of R functions.
  • The collaboratoR package as presented at eRum 2020 extracts graphs of collaborators from a version control history rather than graphs of functions.