Title: | Graph the Relationship Between Functions in an R Package |
---|---|
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. |
Authors: | David Oliver [aut, cre, cph] |
Maintainer: | David Oliver <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.0 |
Built: | 2024-10-31 03:04:29 UTC |
Source: | https://gitlab.com/doliv071/pkggraphr |
Generates the Nodes and Edges of a set of functions in an R package or directory
buildPackageGraph(x, unique.edges = TRUE, only.connected = FALSE)
buildPackageGraph(x, unique.edges = TRUE, only.connected = FALSE)
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 |
A named list of length 2 containing a character vector of nodes and a data.frame of edges.
system.file("extdata", package = "pkgGraphR") |> buildPackageGraph()
system.file("extdata", package = "pkgGraphR") |> buildPackageGraph()
collect all the functions defined in an R program, directory, or file
collectFunNames(x)
collectFunNames(x)
x |
A character string specifying the path to an R package, directory, or file |
A named list of function assignments in each '.R' file in 'x'
system.file("extdata", package = "pkgGraphR") |> collectFunNames()
system.file("extdata", package = "pkgGraphR") |> collectFunNames()
From a list of nodes and edges, plots a diagram or graph
plotPackageGraph(graph, fun.list, use.subgraphs = FALSE, use.colors = FALSE)
plotPackageGraph(graph, fun.list, use.subgraphs = FALSE, use.colors = FALSE)
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 |
A grviz plot.
collectFunNames
, buildPackageGraph
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)
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)