get_nodes {DiagrammeR} | R Documentation |
Obtain a vector of node ID values from a graph object or a node data frame. An optional filter by node attribute can limit the set of node ID values returned.
get_nodes(x, node_attr = NULL, match = NULL)
x |
either a graph object of class |
node_attr |
an optional character vector of node attribute values for filtering the node ID values returned. |
match |
an option to provide a logical expression with a comparison
operator ( |
a vector of node ID values.
## Not run: # Before getting node ID values, create a simple graph nodes <- create_nodes(nodes = c("a", "b", "c", "d"), type = "letter", color = c("red", "green", "grey", "blue"), value = c(3.5, 2.6, 9.4, 2.7)) graph <- create_graph(nodes_df = nodes) # Get a vector of all nodes in a graph get_nodes(graph) #> [1] "a" "b" "c" "d" # Get a vector of node ID values from a node data frame get_nodes(nodes) #> [1] "a" "b" "c" "d" # Get a vector of node ID values using a numeric # comparison (i.e., all nodes with 'value' attribute # greater than 3) get_nodes(graph, node_attr = "value", match = "> 3") #> [1] "a" "c" # Get a vector of node ID values using a match # pattern (i.e., all nodes with 'color' attribute # of "green") get_nodes(graph, node_attr = "color", match = "green") #> [1] "b" ## End(Not run)