check_gr: Check that a node attribute exists for a graph

Description Usage Arguments Value Examples

View source: R/utilities.R

Description

If the node attribute exists, TRUE is returned silently; otherwise the function throws an informative error.

Usage

1
check_gr(gr, node_attr)

Arguments

gr

a tidygraph graph object

node_attr

name of node attribute to check for

Value

(silently) TRUE or throws an error with the message: "<node_attr> not a node attribute in the graph"

Examples

1
2
3
4
gr <- tidygraph::create_ring(5)
gr <- tidygraph::mutate(gr, new_attr = LETTERS[1:5])
check_result <- check_gr(gr, "new_attr")
print(check_result)

jhrcook/wext documentation built on May 17, 2021, 1:19 a.m.