Description Usage Arguments Value See Also Examples
Two trees are equal if they have the same edges. This means that two trees that differ in some respect other than their edges will nonetheless be considered equal.
1 | tree_equal(tree1, tree2)
|
tree1 |
Tree object. |
tree2 |
Tree object. |
Returns TRUE if ‘tree1’ and ‘tree2’ have the same edges.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | library(treeFun)
d1 <- read.table(textConnection("\
id parents label
0 - a
1 0 b
2 0 c
3 1 d
4 1 e
5 1 f
6 2 g
7 2 h
8 7 i
"), header = TRUE, stringsAsFactors = FALSE)
## 0a
## / \
## / \
## 1b 2c
## /|\ / \
## / | \ / \
## 3d 4e 5f 6g 7h
## \
## \
## 8i
d2 <- d1
d2$label <- toupper(d1$label)
d2 <- d2[sample.int(nrow(d2)),]
## d2 has the same structure as d1 but its labels are in uppercase and
## its rows are permuted.
tree_equal(make_tree(d1), make_tree(d2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.