knitr::opts_chunk$set(echo = TRUE) library(DevGRaph)
This vignette describes possibilities for the package DevGRaph with the toy example given in the package.
This package was developped to ease package development. For this reason, it will source R script files from a unique folder.
In this vignette the files are located in inst/extdata
.
path<-system.file("extdata", package = "DevGRaph")
In addition, user can provide information on the state of a function with the gTag.
A gTag is a tag that can be added to the function corpus as a comment with following syntax:
#'gTag status
The status of the function will then be represented by a color in the different graphs.
The following statuses are currently available:
knitr::kable(data.frame(Status = c("unkown (default)","complete","undocumented","ongoing"),Color = c("grey","green","red","orange")))
DevGraphLab
is a function designed to show all interactions between functions of the graph. Each panel represents an independant cluster of functions. This is a wrap-up function that calls GraphLab
to analyze the scripts, looks for independant clusters and plots each one of them with PlotGraphLab
.
DevGraphLab(path = path)
We can here see that two interaction clusters coexist: one containing a single function Outsider
and one starting with Start
.
First we need to analyze the collection of scripts with GraphLab
.
Graph<-GraphLab(path = path)
The graph object is a list of three elements: Functions
(a list of data frames), interaction
, and status
.
interaction
is a binary matrix with a 1 if the function from the column calls the function from the row. Below we show the last two columns of the interaction matrix of the toy example.
knitr::kable(Graph$interaction[,c("Start","progeny")])
We can see that Start
calls all function but calls_ggplot2_function
, recursive
, and Start
itself.
If we wanted to plot the interaction of Start
with its successive progenies, we would write:
PlotGraphLab(GraphLab = Graph,func = "Start")
We can also chose to filter out the packages from which imports are listed. By default, "base" and "utils" packages are hidden from the plots. To show them, we can use:
PlotGraphLab(GraphLab = Graph,func = "Start",filterOut = "")
And to hide another package, for example ggplot2:
PlotGraphLab(GraphLab = Graph,func = "Start",filterOut = c("base","utils","ggplot2"))
We show conflicts of function names for packages that are loaded in the environment.
Let's focus on Outsider
and its calls:
PlotGraphLab(GraphLab = Graph,func = "Outsider",filterOut = "")
We can see here that rbind
that was previously masked as being part of base
package is now shown and belongs to two packages: methods
and base
.
For convenience, the tags can be changed with a dictionnary, either because the project requires different tags, or simply to change the colors of the plot. For example to edit the colors of the default dictionnary
PlotGraphLab(GraphLab = Graph,func = "Start",dictionnary = c(complete = "seagreen", ongoing="gold", undocumented = "purple"))
As shown here, the unknown
parameter is not required for the dictionnary, but one can use it nonetheless to change the color used to display function with unknown tags (either missing or unrecognized).
PlotGraphLab(GraphLab = Graph,func = "Start",dictionnary = c(complete = "seagreen",ongoing ="gold", undocumented = "purple", unknown = "skyblue"))
The color of the outer box can be modified with the color
parameter, as shown below
PlotGraphLab(GraphLab = Graph,func = "Start",color = "white")
Sometimes, for readability, it can be useful to straighten arrows, this can be setting arrow_curv
to zero:
PlotGraphLab(GraphLab = Graph,func = "Start",arrow_curv = 0)
By default, the curvature is set to -0.2.
DevGraphLab
All these arguments can be passed to DevGraphLab
to edit the plot in the same manner as one would do with PlotGraphLab
.
DevGraphLab(path = path,dictionnary = c(complete = "seagreen",ongoing ="gold", undocumented = "purple", unknown = "skyblue"),arrow_curv = 0 , color = "grey40")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.