Description Usage Arguments Details Value Examples
get_parents() returns all parents, grandparents, grand grandparents, etc. of your input node.
1 | get_parents(graph_dt, get_node, return_nodes = TRUE)
|
graph_dt |
data.table; A data.table with a "from" and a "to" column. See details for more. |
get_node |
character; The name of the node(s) who's parents you are looking for |
return_nodes |
logical; If TRUE (default) the function will return both the inputted graph_dt along with a nodes data.table. See return for more. |
The function takes as its input a data.table (graph_dt) with at least two columns called "from" and "to" and potentially many more.
It will return the inputted graph_dt data.table but only with parents included.
If return_nodes is TRUE it will also retun a data.table with node ids including a column called level showing you how many generations there are between the diffent nodes and the inputted node (get_node).
When return_nodes is TRUE it returns both data.tables in a list called nodes and edges.
1 2 3 4 5 6 7 8 | my_network <- data.table::data.table(
from = c("A", "A", "B", "C", "X", "Y", "D"),
to = c("B", "C", "D", "E", "Y", "Z", "E")
)
my_parents <- get_parents(my_network, "B")
my_parents <- get_parents(my_network, "E", return_nodes = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.