knitr::opts_chunk$set(echo = TRUE)
library(DevGRaph)

Getting started with DevGRaph

This vignette describes possibilities for the package DevGRaph with the toy example given in the package.

Setting up the files for analysis

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")))

Viewing all functions from package

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.

Zooming on a specific function

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"))

Show conflicting function names from two packages

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.

Changing parameters

Changing the dictionnary

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"))

Changing box color

The color of the outer box can be modified with the color parameter, as shown below

PlotGraphLab(GraphLab = Graph,func = "Start",color = "white")

Changing arrow curvature

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.

Passing plot arguments to 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")


DeveauP/RDevGraphlab documentation built on May 6, 2019, 2:12 p.m.