unnest_tree | R Documentation |
Unnest a recursive data frame
unnest_tree(
data,
id_col,
child_col,
level_to = "level",
parent_to = "parent",
ancestors_to = NULL
)
data |
A data frame. |
id_col |
A column that uniquely identifies each observation. |
child_col |
Column containing the children of an observation. This must
be a list where each element is either |
level_to |
A string ( |
parent_to |
A string ( |
ancestors_to |
A string ( |
A data frame.
df <- tibble(
id = 1L,
name = "a",
children = list(
tibble(
id = 11:12,
name = c("b", "c"),
children = list(
NULL,
tibble(
id = 121:122,
name = c("d", "e")
)
)
)
)
)
unnest_tree(
df,
id_col = "id",
child_col = "children",
level_to = "level",
parent_to = "parent",
ancestors_to = "ancestors"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.