Title: | Hive Plots of R Package Function Calls |
---|---|
Description: | Analyzes the function calls in an R package and creates a hive plot of the calls, dividing them among functions that only make outgoing calls (sources), functions that have only incoming calls (sinks), and those that have both incoming calls and make outgoing calls (managers). Function calls can be mapped by their absolute numbers, their normalized absolute numbers, or their rank. FuncMap should be useful for comparing packages at a high level for their overall design. Plus, it's just plain fun. The hive plot concept was developed by Martin Krzywinski (www.hiveplot.com) and inspired this package. Note: this package is maintained for historical reasons. HiveR is a full package for creating hive plots. |
Authors: | Bryan A. Hanson DePauw University, Greencastle Indiana USA |
Maintainer: | Bryan A. Hanson <[email protected]> |
License: | GPL-3 |
Version: | 1.0.10 |
Built: | 2024-10-29 04:15:52 UTC |
Source: | https://github.com/bryanhanson/funcmap |
Analyzes the function calls in an R package and creates a hive plot of the calls, dividing them among functions that only make outgoing calls (sources), functions that have only incoming calls (sinks), and those that have both incoming calls and make outgoing calls (managers). Function calls can be mapped by their absolute numbers, their normalized absolute numbers, or their rank. FuncMap should be useful for comparing packages at a high level for their overall design. Plus, it's just plain fun. The hive plot concept was developed by Martin Krzywinski (www.hiveplot.com) and inspired this package. Note: this package is maintained for historical reasons. HiveR is a full package for creating hive plots. FuncMap contains only one function, FuncMap
. It is released under the GPL-3 license.
Bryan A. Hanson DePauw University, Greencastle Indiana USA
Maintainer: Bryan A. Hanson <[email protected]>
FuncMap was inspired by the work of Martin Krzywinski on hive plots (www.hiveplot.com).
FuncMap analyzes the function calls in an R package and creates a hive plot of the calls, dividing them among functions that only make outgoing calls (sources), functions that have only incoming calls (sinks), and those that have both incoming calls and make outgoing calls (managers). Function calls can be mapped by their absolute numbers, their normalized absolute numbers, or their rank. FuncMap should be useful for comparing packages at a high level for their overall design. Plus, it's just plain fun and makes great artwork!
FuncMap(fwb = foodweb, pkg = "none", method = "abs", sm.title = FALSE, newpage = TRUE, debug = FALSE)
FuncMap(fwb = foodweb, pkg = "none", method = "abs", sm.title = FALSE, newpage = TRUE, debug = FALSE)
fwb |
An object of class |
pkg |
The name of the package being analyzed; used for the plot title. |
method |
One of |
sm.title |
Logical. Defaults to |
newpage |
Logical. Defaults to |
debug |
Logical. Defaults to |
The list of which functions call which other functions is in fwb$funmat
, and is used to determine which functions are sources, managers and sinks. In the process, the total number of outgoing calls are determined for source functions, the total of incoming and outgoing calls is calculated for managers, and the total incoming calls determined for sink functions. Each is plotted on the appropriate axis as either the absolute numbers, the normalized absolute numbers, or by rank. The absolute plot axis lengths give a sense of which kind of functions dominate in a package, and whether there are a few functions that do most of the work. The normalized plot axes are the same length, which spreads out the absolute plot but is otherwise the same data. For the absolute and norm plots, where there is more than one function making n
calls to another function which receives p
calls, the line width of the spline curve is set to n
. Also, a black dot is plotted at each position along the axis where there is a function. The rank plot spreads out the functions so that each function has a unique position on the axis; each node connects to only one other node and hence the linewidths are all 1. If there are stand alone functions that make no calls at all, these are plotted as a dot at the center of the hive.
Some relatively simple packages that make interesting plots are pcaPP
and cluster
. More complex packages are survival
, colorspace
and rgl
. Quite complex packages are lattice
, mclust
and ggplot2
. colorspace
is quite interesting if you compare the absolute and rank plots. seriation
and mvoutlier
are packages that have no manager functions.
For package MASS
and presumably some others, only part of the hive plot is drawn before throwing an error. This is the result of how foodweb
reads code and determines when a function has been called (M. Bravington, personal communication).
A list of two data frames:
points |
Coordinates of the points (nodes) to be plotted on each axis, representing the counts of calls (in absolute, normalized or ranked units). |
curves |
Coordinates and line widths for drawing the edges, which are spline curves representing the calls. |
Bryan A. Hanson <[email protected]>
The hive plot concept was developed by Martin Krzywinski (www.hiveplot.com) and inspired this package.
Function foodweb
in package mvbutils
.
require(mvbutils) require(lattice) require(grid) # draw the foodweb using mvbutils fw <- foodweb(where = "package:lattice", charlim = 20, cex = 0.5, lwd = 1) # draw the hive plot ans <- FuncMap(fwb = fw, pkg = "lattice", method = "abs")
require(mvbutils) require(lattice) require(grid) # draw the foodweb using mvbutils fw <- foodweb(where = "package:lattice", charlim = 20, cex = 0.5, lwd = 1) # draw the hive plot ans <- FuncMap(fwb = fw, pkg = "lattice", method = "abs")