Evaluate the expression in tidygraph::filter(expr)
and
return the indices of the remaining nodes
get_node_index(gr, expr)
gr | tidygraph graph object |
---|---|
expr | an expression to evaluate in |
a vector of the indices of the nodes remaining after the filter
suppressPackageStartupMessages(library(magrittr)) suppressPackageStartupMessages(library(tidygraph)) tidygraph::create_ring(5) %>% mutate(name = LETTERS[1:5]) %>% get_node_index(name != "B")#> [1] 1 3 4 5