FunctionReporter | R Documentation |
This reporter looks at the network of interdependencies of its defined functions. Measures of centrality from graph theory can indicate which function is most important to a package. Combined with unit test coverage information—also provided by this reporter— it can be used as a powerful tool to prioritize test writing.
R6 classes are supported, with their methods treated as functions by the reporter.
R6 methods will be named like
<classname>$<methodtype>$<methodname>
, e.g.,
FunctionReporter$private_methods$extract_nodes
.
Note that the class name used will be the name of the generator object in the package's namespace.
The classname
attribute of the class is not used.
In general, it is not required to be defined or the same as the
generator object name. This attribute is used primarily for
S3 dispatch.
Using non-standard evaluation to refer to things (e.g, dataframe
column names) that have the same name as a function will trick
FunctionReporter
into thinking the function was called. This
can be avoided if you don't use reuse function names for other
purposes.
Functions stored as list items and not assigned to the package
namespace will be invisible to FunctionReporter
.
Calls to methods of instantiated R6 or reference objects will not be recognized. We don't have a reliable way of identifying instantiated objects, or identifying their class.
Reference class methods are not yet supported. They will not be
identified as nodes by FunctionReporter
.
FunctionReporter$new()
Initialize an instance of the reporter.
Returns:
Instantiated reporter object. Note that this
reporter object isn't useful yet until you use the
set_package
method to set a package.
set_package(pkg_name, pkg_path = NULL)
Set the package that the reporter will analyze. This can only be done once for a given instance of a reporter. Instantiate a new copy of the reporter if you need to analyze a different package.
Args:
pkg_name
: character string, name of
package
pkg_path
: character string, optional
directory path to source code of the package. It is used
for calculating test coverage. It can be an absolute or
relative path.
Returns:
Self, invisibly.
get_summary_view()
Returns an htmlwidget object that summarizes the analysis of the reporter. Used when creating a package report.
Returns:
htmlwidget object
calculate_default_measures()
Calculates the default node and network measures for this reporter.
Returns:
Self, invisibly.
pkg_name
character string, name of set package. Read-only.
report_markdown_path
character string, path to R Markdown template for this reporter. Read-only.
nodes
a data.table, containing information about
the nodes of the network the reporter is analyzing. The node
column acts the identifier. Read-only.
edges
a data.table, containing information about
the edge connections of the network the reporter is analyzing. Each
row is one edge, and the columns SOURCE
and TARGET
specify the node identifiers. Read-only.
network_measures
a list, containing any measures of the network calculated by the reporter. Read-only.
pkg_graph
a graph model object. See DirectedGraph for additional documentation. Read-only.
graph_viz
a graph visualization object. A
visNetwork::visNetwork
object.
Read-only.
layout_type
a character string, the current layout
type for the graph visualization. Can be assigned a new valid layout
type value. Use use
grep("^layout_\\S", getNamespaceExports("igraph"), value = TRUE)
to see valid options.
clone(deep = FALSE)
Method for copying an object. See Advanced R for the intricacies of R6 reference semantics.
Args:
deep
: logical. Whether to recursively
clone nested R6 objects.
Returns:
Cloned object of this class.
Other Network Reporters:
DependencyReporter
,
InheritanceReporter
Other Package Reporters:
DependencyReporter
,
InheritanceReporter
,
SummaryReporter
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.