| Title: | Makes interactive network graphs using r2d3 |
|---|---|
| Description: | Makes interactive network graphs using r2d3. |
| Authors: | CJ Yetman [aut, cre] (ORCID: <https://orcid.org/0000-0001-5099-9500>), Mike Bostock [cph] (d3-sankey library, https://github.com/d3/d3-sankey) |
| Maintainer: | CJ Yetman <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-06-05 07:29:39 UTC |
| Source: | https://github.com/cjyetman/network.r2d3 |
The force_network function uses a 'native' data format that consists of a...
as_force_data(.data, ...) ## S3 method for class 'character' as_force_data(.data, ...) ## S3 method for class 'data.frame' as_force_data(.data, ...) ## S3 method for class 'igraph' as_force_data(.data, ...) ## S3 method for class 'hclust' as_force_data(.data, ...) ## S3 method for class 'dendrogram' as_force_data(.data, ...) ## S3 method for class 'list' as_force_data(.data, ...)as_force_data(.data, ...) ## S3 method for class 'character' as_force_data(.data, ...) ## S3 method for class 'data.frame' as_force_data(.data, ...) ## S3 method for class 'igraph' as_force_data(.data, ...) ## S3 method for class 'hclust' as_force_data(.data, ...) ## S3 method for class 'dendrogram' as_force_data(.data, ...) ## S3 method for class 'list' as_force_data(.data, ...)
.data |
a force network description in one of numerous forms (see details). |
... |
other arguments that will be passed on to as_force_data |
as_force_data(character): Convert data found at a URL to an appropriate
network data list
as_force_data(data.frame): Convert a data frame containing links data to an
appropriate network data list
as_force_data(igraph): Convert an igraph object to an appropriate network
data list
as_force_data(hclust): Convert a hclust object to an appropriate network
data list
as_force_data(dendrogram): Convert a dendrogram object to an appropriate network
data list
as_force_data(list): Convert a list object containg a links and a nodes
data frame to an appropriate network data list
The sankey_network function uses a 'native' data format that consists of a...
as_sankey_data(.data, ...)as_sankey_data(.data, ...)
.data |
a sankey network description in one of numerous forms (see details). |
... |
other arguments that will be passed on to as_sankey_data |
The tree_network function uses a 'native' data format that consists of a data
frame with minimally 2 vectors/columns, one named 'nodeId' and one named
'parentId'. Other columns in the data frame are also passed on to the
JavaScript code and attached to the elements in the D3 visualization so that
they can potentially be accessed by other JavaScript functions. This is an
advantageous format because:
it's an easy to use and understand R-like format
a hierarchical network can be succinctly defined by a list of each unique node and its parent node
since each row defines a unique node, additional columns can be added to add node-specific properties
in a hierarchical network, every link/edge can be uniquely identified by the node which it leads to, therefore each link/edge can also be specifically addressed by adding columns for formatting of the incoming link
as_tree_data can convert from any of the following data types:
leafpathdf (table)–parent|parent|node–data.frame
hierarchical nested list (JSON)
hclust
data.tree Node
igraph
ape phylo
as_tree_data(data, ...) ## S3 method for class 'character' as_tree_data(data, ...) ## S3 method for class 'hclust' as_tree_data(data, ...) ## S3 method for class 'list' as_tree_data(data, children_name = "children", node_name = "name", ...) ## S3 method for class 'Node' as_tree_data(data, ...) ## S3 method for class 'phylo' as_tree_data(data, ...) ## S3 method for class 'tbl_graph' as_tree_data(data, ...) ## S3 method for class 'igraph' as_tree_data(data, root = "root", ...) ## S3 method for class 'data.frame' as_tree_data( data, cols = NULL, df_type = "treenetdf", subset = names(data), root, ... )as_tree_data(data, ...) ## S3 method for class 'character' as_tree_data(data, ...) ## S3 method for class 'hclust' as_tree_data(data, ...) ## S3 method for class 'list' as_tree_data(data, children_name = "children", node_name = "name", ...) ## S3 method for class 'Node' as_tree_data(data, ...) ## S3 method for class 'phylo' as_tree_data(data, ...) ## S3 method for class 'tbl_graph' as_tree_data(data, ...) ## S3 method for class 'igraph' as_tree_data(data, root = "root", ...) ## S3 method for class 'data.frame' as_tree_data( data, cols = NULL, df_type = "treenetdf", subset = names(data), root, ... )
data |
a tree network description in one of numerous forms (see details). |
... |
other arguments that will be passed on to as_tree_data |
children_name |
character specifying the name used for the list element that contains the childeren elements. |
node_name |
character specifying the name used for the list element that contains the name of the node |
root |
root name. |
cols |
named character vector specifying the names of columns to be
converted to the standard |
df_type |
character specifying which type of data frame to convert. Can
be |
subset |
character vector specifying the names of the columns (in order) that should be used to define the hierarchy. |
as_tree_data(character): Convert JSON from URL to treenetdf
as_tree_data(hclust): Convert hclust objects to treenetdf
as_tree_data(list): Convert a nested list to treenetdf
as_tree_data(Node): data.tree to treenetdf
as_tree_data(phylo): Phylo tree to treenetdf
as_tree_data(tbl_graph): tbl_graph_to_treenetdf
as_tree_data(igraph): Convert igraph tree to treenetdf
as_tree_data(data.frame): Convert a data.frame to a treenetdf
links <- read.csv(header = TRUE, stringsAsFactors = FALSE, text = ' source,target,name 1,,one 2,1,two 3,1,three 4,1,four 5,2,five 6,2,six 7,2,seven 8,6,eight') # Convert data as_tree_data(links, cols = c(nodeId = 'source', parentId = 'target'))links <- read.csv(header = TRUE, stringsAsFactors = FALSE, text = ' source,target,name 1,,one 2,1,two 3,1,three 4,1,four 5,2,five 6,2,six 7,2,seven 8,6,eight') # Convert data as_tree_data(links, cols = c(nodeId = 'source', parentId = 'target'))
force_network options explorerAn interactive shiny widget to explore the force_network options.
force_explorer(data)force_explorer(data)
data |
a network description in one of numerous forms (see details) |
The force_network function creates an interactive force network plot in a
htmlwidget
force_network(data, width = NULL, height = NULL, ..., viewer = "internal")force_network(data, width = NULL, height = NULL, ..., viewer = "internal")
data |
a tree network description in one of numerous forms (see details) |
width, height
|
width and height of exported htmlwidget in pixels (single integer value; default == NULL) |
... |
other options (see details) |
viewer |
whether to view the plot in the internal viewer or browser |
sankey_network options explorerAn interactive shiny widget to explore the sankey_network options.
sankey_explorer(data)sankey_explorer(data)
data |
a network description in one of numerous forms (see details) |
The sankey_network function creates an interactive sankey network plot in
a htmlwidget
sankey_network(data, width = NULL, height = NULL, ..., viewer = "internal")sankey_network(data, width = NULL, height = NULL, ..., viewer = "internal")
data |
a network description in one of numerous forms (see details) |
width, height
|
width and height of exported htmlwidget in pixels (single integer value; default == NULL) |
... |
other options (see details) |
viewer |
whether to view the plot in the internal viewer or browser |
The save_as_png function takes a screenshot of a htmlwidget as a PNG image.
save_as_png(widget, filepath, background = "white", delay = 0.5)save_as_png(widget, filepath, background = "white", delay = 0.5)
widget |
a htmlwidget |
filepath |
a filepath where to save the file |
background |
the background color underneath/behind the htmlwidget |
delay |
a delay (in seconds) to wait before taking the screenshot |
The save_as_svg function takes a screenshot of a htmlwidget as a SVG image.
save_as_svg(widget, filepath, background = "white", delay = 0.5)save_as_svg(widget, filepath, background = "white", delay = 0.5)
widget |
a htmlwidget |
filepath |
a filepath where to save the file |
background |
the background color underneath/behind the htmlwidget |
delay |
a delay (in seconds) to wait before taking the screenshot |
tree_network options explorerAn interactive shiny widget to explore the tree_network options.
tree_explorer(data)tree_explorer(data)
data |
a tree network description in one of numerous forms (see details) |
The tree_network function creates an interactive tree network plot in an htmlwidget
tree_network( data, width = NULL, height = NULL, treeType = "tidy", direction = "right", linkType = "diagonal", ..., viewer = "internal" )tree_network( data, width = NULL, height = NULL, treeType = "tidy", direction = "right", linkType = "diagonal", ..., viewer = "internal" )
data |
a tree network description in one of numerous forms (see details) |
width, height
|
width and height of exported htmlwidget in pixels (single integer value; default == NULL) |
treeType |
type of tree; one of "tidy" or "cluster" (see details) (default == "tidy") |
direction |
direction toward which the tree grows; one of "right", "left", "down", or "up" (see details) (default == "right") |
linkType |
type on link shape; one of "diagonal" or "elbow" (see details) (default == "diagonal") |
... |
other options (see details) |
viewer |
whether to view the plot in the internal viewer or browser |
treedf <- data.frame(nodeId = LETTERS[1:7], parentId = c("", "A", "A", "B", "B", "C", "C"), name = LETTERS[1:7], stringsAsFactors = FALSE) tree_network(treedf)treedf <- data.frame(nodeId = LETTERS[1:7], parentId = c("", "A", "A", "B", "B", "C", "C"), name = LETTERS[1:7], stringsAsFactors = FALSE) tree_network(treedf)