Tomas
Tomas

Reputation: 59435

How to make a static function call graph with regard to source files in R?

I want to make a call graph, that would:

  1. Be static, i.e. not based on particular code run (or profiling), but all possible calls in all branches.
  2. The functions should be grouped together according to the source *.R file of their definition.
  3. Should not require to have code wrapped as a package. (I have an extensive code with many *.R files containing many functions. I don't have a package yet - too early in the development, it has yet to be determined, what parts of code would constitute what package(s) etc).
  4. I want an export to a format where I can drag around the nodes and the arrows would automatically follow (be snapped to the nodes).

At the moment, I have come up with this, but it is still short on conditions 2 and 4 above:

f <- function (x)
{
    x + 1
}

g <- function (y)
{
    f(y)*2
}

h <- function (x, y)
{
    f(x)+g(y)
}

library(foodwebr)

x <- foodweb(h)
plot(x)

enter image description here

Upvotes: 0

Views: 40

Answers (0)

Related Questions