R/account_with_tag_parents.R
with_tag_parents.Rd
Adds a column called parent
to a table. This is the ID
of a tag's parent tag. Since tags can have multiple parents,
we need to know what the ultimate root parent to determine
"parenthood" is. This is done using the parent_id
parameter.
with_tag_parents(tags, parent_id)
tags | A tibble of tags to find parents for |
---|---|
parent_id | A root parent that all children are determined from |
The same tags tibble, but annotated with a parent
column
#> # A tibble: 6 x 9 #> # Rowwise: #> id name namespace description deleted forClassificati… children is_parent #> <int> <chr> <chr> <chr> <lgl> <lgl> <list> <lgl> #> 1 1 tag1 tag NA FALSE FALSE <NULL> FALSE #> 2 2 tag2 tag Deleted TRUE FALSE <NULL> FALSE #> 3 10 Paren… topic Has childr… FALSE FALSE <int [2… TRUE #> 4 11 Child… topic I am a chi… FALSE FALSE <NULL> FALSE #> 5 12 Child… topic I am also … FALSE FALSE <NULL> FALSE #> 6 1001 Tree … topic_tr… Topics com… FALSE FALSE <int [1… TRUE #> # … with 1 more variable: parent <dbl>#> # A tibble: 1 x 6 #> id name description deleted forClassification children #> <int> <chr> <chr> <lgl> <lgl> <list> #> 1 1001 Tree of Topics Topics come from here FALSE FALSE <int [1]># Tag 1001 is a topic tree. Let's find # topics, with parents, that are part of this tree. account("TEST01AA") %>% tags() %>% with_tag_parents(1001) %>% dplyr::filter(namespace == 'topic') %>% dplyr::arrange(desc(is_parent), name)#> # A tibble: 3 x 9 #> # Rowwise: #> id name namespace description deleted forClassificati… children is_parent #> <int> <chr> <chr> <chr> <lgl> <lgl> <list> <lgl> #> 1 10 Paren… topic Has childr… FALSE FALSE <int [2… TRUE #> 2 11 Child… topic I am a chi… FALSE FALSE <NULL> FALSE #> 3 12 Child… topic I am also … FALSE FALSE <NULL> FALSE #> # … with 1 more variable: parent <dbl>