| Type: | Package | 
| Title: | Graph the Relationship Between Functions in an R Package | 
| Version: | 0.3.1 | 
| Maintainer: | David Oliver <doliv071@gmail.com> | 
| BugReports: | https://gitlab.com/doliv071/pkggraphr/-/issues | 
| URL: | https://gitlab.com/doliv071/pkggraphr | 
| Description: | It is often useful when developing an R package to track the relationship between functions in order to appropriately test and track changes. This package generates a graph of the relationship between all R functions in a package. It can also be used on any directory containing .R files which can be very useful for 'shiny' apps or other non-package workflows. | 
| License: | GPL (≥ 3) | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.3.2 | 
| Imports: | DiagrammeR, dplyr, purrr, stats, utils | 
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) | 
| Config/testthat/edition: | 3 | 
| VignetteBuilder: | knitr | 
| NeedsCompilation: | no | 
| Packaged: | 2025-01-03 18:21:50 UTC; oliverd | 
| Author: | David Oliver [aut, cre, cph] | 
| Repository: | CRAN | 
| Date/Publication: | 2025-01-07 15:20:08 UTC | 
Build a graph of an R package or directory
Description
Generates the Nodes and Edges of a set of functions in an R package or directory
Usage
buildPackageGraph(x, unique.edges = TRUE, only.connected = FALSE)
Arguments
| x | A character string specifying the path to an R package or directory | 
| unique.edges | Logical indicating whether there should be only a single edge between nodes. DEFAULT: TRUE | 
| only.connected | Logical indicating whether unconnected nodes should be removed from the graph. DEFAULT: FALSE | 
Value
A named list of length 2 containing a character vector of nodes and a data.frame of edges.
Examples
system.file("extdata", package = "pkgGraphR") |>
    buildPackageGraph()
Collect all functions in a package or directory
Description
collect all the functions defined in an R program, directory, or file
Usage
collectFunNames(x)
Arguments
| x | A character string specifying the path to an R package, directory, or file | 
Value
A named list of function assignments in each '.R' file in 'x'
Examples
system.file("extdata", package = "pkgGraphR") |>
    collectFunNames()
Plot a graph or diagram of a package
Description
From a list of nodes and edges, plots a diagram or graph
Usage
plotPackageGraph(graph, fun.list, use.subgraphs = FALSE, use.colors = FALSE)
Arguments
| graph | A list generated by  | 
| fun.list | An optional list generated by  | 
| use.subgraphs | Logical indicating whether the graph should be partitioned into subgraphs by the file in which the function assignment was made. DEFAULT: FALSE | 
| use.colors | Logical indicating whether the nodes of the graph should be colored by the file in which the function assignment was made. N.B. No legend is plotted for the colors. DEFAULT: FALSE | 
Value
A grviz plot.
See Also
collectFunNames, buildPackageGraph
Examples
pkgGraph <- system.file("extdata", package = "pkgGraphR") |>
    buildPackageGraph()
plotPackageGraph(graph = pkgGraph)
pkgFuns <- system.file("extdata", package = "pkgGraphR") |>
    collectFunNames()
plotPackageGraph(graph = pkgGraph, fun.list = pkgFuns, use.subgraphs = TRUE)
plotPackageGraph(graph = pkgGraph, fun.list = pkgFuns, use.colors = TRUE)
plotPackageGraph(graph = pkgGraph, fun.list = pkgFuns, use.colors = TRUE, use.subgraphs = TRUE)