I have the following dataset.
data <- data.frame("group1" = c(rep("a",10),rep("b",10)),"group2" = c(rep(c("a","b"),5),rep(c("c","d"),5)))
data
group1 group2
1 a a
2 a b
3 a a
4 a b
5 a a
6 a b
7 a a
8 a b
9 a a
10 a b
11 b c
12 b d
13 b c
14 b d
15 b c
16 b d
17 b c
18 b d
19 b c
20 b d
I then use the create_tree
function from the shinyWidgets package, which gives me a list with the following structure.
tree <- create_tree(data)
str(tree)
List of 2
$ :List of 3
..$ text : chr "a"
..$ id : chr "tree7337428"
..$ children:List of 2
.. ..$ :List of 2
.. .. ..$ text: chr "a"
.. .. ..$ id : chr "tree7904513"
.. ..$ :List of 2
.. .. ..$ text: chr "b"
.. .. ..$ id : chr "tree7346861"
$ :List of 3
..$ text : chr "b"
..$ id : chr "tree6379478"
..$ children:List of 2
.. ..$ :List of 2
.. .. ..$ text: chr "c"
.. .. ..$ id : chr "tree500704"
.. ..$ :List of 2
.. .. ..$ text: chr "d"
.. .. ..$ id : chr "tree8058601"
From this list, I would like to obtain the following dataset.
group1 group2 tree_id
1 a a tree7904513
2 a b tree7346861
3 b c tree500704
4 b d tree8058601
So basically I want to extract the terminal id's from the list. Any help appreciated.