Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visualizing R code with a flow chart

Are there any tools that can visualize R code?

I have some very complex R code split between several scripts that I need to understand. Part of the difficulty of this is that there are so many nested functions and variables that it's proving extremely slow going to go through it manually and figure out what connects to what.

I think my task might be easier if there were some way to generate a flow chart from R code, so that I can see it all at once. Of course, I can just draw out a map as I go through the code, but shouldn't it be programatically possible to do this? Are there any existing tools that can do it?

I have found a program called R AnalyticFlow, but it seems to MAKE scripts using a GUI, whereas I want something that can take code and make it into the type of thing that one would draw in AnalyticFlow.

like image 747
Stonecraft Avatar asked Feb 21 '18 21:02

Stonecraft


2 Answers

You can visualize your functions in a easy way using the mvbills package.

Install/import

install.packages("mvbutils", dependencies = TRUE)
library(mvbutils)

And use

foodweb(where = environment())

In my case, an example of output would be:

enter image description here

Or if it's a package (or you just want to try other option), you can use the DependenciesGraphs package.

like image 156
Felipe Augusto Avatar answered Oct 11 '22 01:10

Felipe Augusto


Even though this question is already a bit old there is a nice R-package called flow that might be very useful for the task:

https://moodymudskipper.github.io/flow/index.html

It graphically visualizes functions, if-then-else statements and more.

like image 34
shghm Avatar answered Oct 11 '22 01:10

shghm