I need to work with relatively large R code written by someone else. The code has no documentation, and it is divided into countless files, each of which may contain one or more functions. The original author did not use the Makefile, so there is no documentation on what causes what.
As a first step, I would like to create a dendrogram. I mean a tree whose root is the main file, internal nodes are different file names, and leaves (terminal nodes) are files that do not call functions defined in other files. Is there any way to do this automatically? The image output will be great, but even a text file will work. R Studio will also be fine.
EDIT : Apparently my description is not clear enough, so I am adding a very simple (trivial, in fact) example. Suppose I have 4 source files main.r , foo.r , bar.r and blargh.r , all in one folder (in the real case there are ~ 50 files, all are “neatly” stored in the same folder with blush, output files). The contents of main.r :
# main.r source("foo.r") source("bar.r") source("blargh.r") foo() bar()
foo.r :
# foo.r foo <- function(){ print("I'm foo") blargh() }
bar.r :
# bar.r bar <- function(){ print("I'm bar") blargh() }
blargh.r
# blargh.r blargh <- function(){ print("I'm blargh") }
I need to create a diagram like this:
main.r ¦--foo.r ¦ ¦ ¦ °--blargh.r ¦ °--bar.r ¦ °--blargh.r
r rstudio diagram call-graph
Deltaiv
source share