
Last chance! 50% off unlimited learning
Sale ends in
From a graph object of class
dgr_graph
, get edge attribute properties for
one or more edges and cache those values in the
graph for later retrieval using get_cache
.
cache_edge_attrs(graph, edge_attr, mode = NULL, from = NULL, to = NULL)
a graph object of class
dgr_graph
.
the edge attribute from which to obtain values.
a option to recast the returned vector
of edge attribute value as numeric
or
character
.
an optional vector of node IDs from which the edge is outgoing for filtering the list of edges present in the graph.
an optional vector of node IDs to which the edge is incoming for filtering the list of edges present in the graph.
a graph object of class dgr_graph
.
# Set a seed
set.seed(25)
# Create a graph with 10 nodes and 9 edges graph <- create_graph() add_n_nodes(10) add_edges_w_string( "1->2 1->3 2->4 2->5 3->6 3->7 4->8 4->9 5->10") set_edge_attrs( "value", rnorm(edge_count(.), 5, 2))
# Cache all values from the edge attribute `value` # as a numeric vector graph <- graph cache_edge_attrs("value", "numeric")
# Get the mean from all values available in # the cache graph #> [1] 4.62536