Add Attributes to Subset of Edges for visNetwork
Source: R/plot-graph.R
set_attributes_to_edges_visnetwork.Rd
A subset of edges can be assign a different thickness or color.
Arguments
- edges
A data.frame create by
create_edges_visnetwork
- subset_edges
A list with the elements
from
andto
. Bothfrom
andto
are vectors of the same length denoting the different edges- width
Vector with two values. The first is assigned to the edges in the subset given by
subset_edges
. The second value is assigned to the rest. Ifwidth = c(NA,NA)
, no width is assigned- color
Vector with two values. The first is assigned to the edges in the subset given by
subset_edges
. The second value is assigned to the rest. Ifcolor = c(NULL,NULL)
, no color is assigned
Examples
nodes <- create_nodes_visnetwork(n_nodes = 5, labels = LETTERS[1:5])
adj_matrix <- matrix(c(0, 1, 0, 1, 0,
1, 0, 1, 0, 0,
0, 1, 0, 0, 0,
1, 0, 0, 0, 1,
0, 0, 0, 1, 0), ncol = 5)
edges <- create_edges_visnetwork(adj_matrix)
shared_edges <- data.frame(from = c(1,2), to = c(4, 3))
edges <- set_attributes_to_edges_visnetwork(edges,
subset_edges = shared_edges,
width = c(3, .5),
color = c("red", "blue"))
visnetwork(nodes, edges)