The main value is in the graphical display. At the top ("level 0"), functions which don't call any others, and aren't called by any others, are shown without any linking lines. Functions which do call others, but aren't called themselves, appear on the next layer ("level 1"), with lines linking them to functions at other levels. Functions called only by level 1 functions appear next, at level 2, and so on. Functions which call each other will always appear on the same level, linked by a bent double arrow above them. The colour of a linking line shows what level of the hierarchy it came from.
foodweb
makes some effort to arrange the functions on the display to keep the number of crossing lines low, but this is a hard problem! Judicious use of prune
will help keep the display manageable. Perhaps counterintuitively, any functions NOT linked to those in prune
(which all will be, by default) will be pruned from the display.
foodweb
tries to catch names of functions that are stored as text, and it will pick up e.g. glm
in do.call( "glm", glm.args)
. There are limits to this, of course (?methods?).
The argument list may be somewhat daunting, but the only ones normally used are funs
, where
, and prune
. Also, to get a readable display, you may need to reduce cex
and/or charlim
. A number of the less-obvious arguments are set by other functions which rely on plot.foodweb
to do their display work. Several may disappear in future versions.
If the display from foodweb
is unclear, try foodweb( .Last.value, cex=<<something below 1>>, charlim=<<something probably less than 100>>)
. This works because foodweb
will also accept a foodweb
-class object as its argument. You can also assign the result of foodweb
to a variable, which is useful if you expect to do a lot of tinkering with the display, or to inspect the who-calls-whom matrix by hand.
callers.of
and callees.of
process the output of foodweb
, looking for immediate dependencies only. The second argument will call foodweb
by default, so it may be more efficient to call foodweb
first and assign the result to a variable. NB you can set recursive=TRUE
for the obvious result.
Bug in rgui windows graphics
When plotting the foodweb, there's a display bug in Rgui for windows which somehow causes the fontsize to shrink in each successive calls! Somehow par("ps")
keeps on shrinking. Indeed, on my own machines, calling par(ps=par("ps"))$ps
will show a decreasing value each time... Working around this was very tricky; variants of saving/restoring par
inside plot.foodweb
do not work. As of package mvbutils version 2.8.142, there's an attempted fix directly in foodweb
, but conceivably the fixe will somehow cause problems for other people using default graphics windows in Rgui. Let me know if that's you... (in which case I'll add an option()
to not apply the fix).