A simple package to map out dependencies between functions in a directory / package using rlang
(in contrast to other regex-based packages). This helps analyse packages and refactor code.
(The package works best for packages with < 50 functions. With larger packages, the diagram would contain too many nodes to be useful.)
update_graph_from_svg
(see Usage 1). ?remove_duplicates
and ?remove_vbar
for more detail if you ran into troubles.build_pkg_graph
(see Usage 1).# At the package directory
g <- funGraphs::build_pkg_graph()
# It's unlikely the graph-arrangement algorithm can get to exactly what you want; you can move the nodes around as you see fit. Once you are done, you can click 'save', then copy the generated svg string into a file and save it as a SVG file, e.g. "test.svg". To load a SVG file, copy the svg string into the textbox provided, then click 'load'. Note that this is read-only. If you wish to continue modifying the graph, use 'update_graph_from_svg' instead:
library(magrittr)
g %>%
update_graph_from_svg("test.svg") %>%
start_app()
library(funGraphs)
library(magrittr)
# At the package directory
g0 <- build_graph_from_dir("R/") # Analyse directory and build
# `prepare_graph` uses `igraph::layout_with_sugiyama` which works well
# with small (<20) number of nodes
g0 %>%
prepare_graph() %>% # Add plotting parameters
start_app() # Display app
# `prepare_graph_Rgraphviz` uses the default in `Rgraphviz` which
# works well for larger number of nodes.
g0 %>%
prepare_graph_Rgraphviz() %>% # Add plotting parameters
start_app() # Display app
From the diagram, we see that build_graph_from_dir
, start_app
and prepare_graph_Rgraphviz
are at the top level. Indeed, they form the interface of the package. (Note that nodes with the same color are from the same file.)
From the diagram, we see that glue_collapse
and glue_data
(and also as_glue.default
, [.glue
, [[.glue
) separate the high-level calls from the low-level functions. From the grouping and naming of the functions, one would guess that
(Minor manual modification, and removal of %||%
and an extra .onLoad
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.