These functions read information from CRAN or within an R package's working directory to create a networks of a package's dependencies:

  • read_cran() creates a network of a package's dependencies on other packages available on CRAN. It looks for the Depends, Imports and Suggests fields in the package's DESCRIPTION file and creates a network where nodes are packages and ties are dependencies.

  • read_pkg() creates a network of function dependencies from R scripts in a directory. It looks for function definitions and function calls within the scripts and creates a network where nodes are functions and edges are function calls. It can also include function calls to functions not defined within the scripts.

read_cran(pkg = "all")

read_pkg(dir = getwd())

Source

https://www.r-bloggers.com/2016/01/r-graph-objects-igraph-vs-network/

https://github.com/STATWORX/helfRlein/blob/master/R/get_network.R

Arguments

pkg

The name

dir

Character string or vector of character strings with the directory or directories to search for R scripts. If NULL (the default), the current working directory is used.

Value

A tidygraph object representing the network of package dependencies or function dependencies in a package.

Details

Note that these functions are not as actively maintained as others in the package, so please let us know if any are not currently working for you or if there are missing import routines by raising an issue on Github.

Author

Jakob Gepp

Examples

# mnet <- read_cran()
# mnet <- to_ego(mnet, "manynet", max_dist = 2)
# mnet <- read_pkg()