Visualization of R function dependencies

There are many resources for people who want to visualize package dependencies, but I'm only interested in visualizing the functions inside the package and their dependencies on each other. There are tools like miniCRAN for graphically displaying package dependencies, but is there anything available for the dependencies of the graph functions inside the package?

For example, suppose I have only two functions in my package.

func1 <- function(n) return(LETTERS[n])
func2 <- function(n) return(func1(n%%26+1))

Then I just need a graph with two labeled nodes and an edge associated with them, depicting the dependence func2on func1.

I would think that there are many packages that have really hairy functional dependencies, which such a utility can help in understanding / organizing / refactoring, etc.

Thanks.

+5
source share
2 answers

I think the best option (built on top of the foodweb mvbutil product features) is the DependenciesGraph package, created by datastorm-open on Github on top of their more general visNetwork .

  • DependenciesGraph : R package for visualizing dependencies between packages and functions

In my example, I visualized my own package for maintenance and development and was very pleased with the results.

library(DependenciesGraph)
library(QualtricsTools) # A package I'm developing
deps <- funDependencies("package:QualtricsTools", "generate_split_coded_comments")
plot(deps)

Dependency Graph generated by DependenciesGraph

- - ( RStudio viewer, ), , , . , R foodweb, , , node, - , R- , , .

mvbutil foodweb:

library(mvbutils)
library(QualtricsTools) 
deps <- foodweb(where="package:QualtricsTools", prune='make_split_coded_comments')
plot(deps)

A foodweb dependency graph of make_split_coded_comments

(, , , ).

+5

foodweb mvbutils.

e <- new.env()
e$func1 <- function(n) return(LETTERS[n])
e$func2 <- function(n) return(func1(n%%26+1))

library(mvbutils)
foodweb(where = e)

. ?mvbtools.

+3

All Articles