Description Usage Arguments Details Value Author(s) Examples
Provide a logical answer to the question "Are two trees equivalent?".
1 | CompareTrees(tree_test, tree_ref)
|
tree_test |
(testing tree) a tree structure in the form of nested lists (as the output of hclust2tree, for example) |
tree_ref |
(reference tree) a tree structure in the form of nested lists (as the output of hclust2tree, for example) |
This test is particularly useful when two trees are not ordered in the same way.
As the structure are lists, one could argue that this function is a modification
of the identical
base function, overcoming the ordering.
boolean: TRUE implies that the two trees are equivalent.
Simon-Pierre Gadoury
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Comparison between "identical" and "compareTrees"
##
## The trees are "identical"
tree1 <- list(list(list(5, 6), list(7, 8), 3, 4), list(9, 10), 2, 1)
tree2 <- list(list(list(5, 6), list(7, 8), 3, 4), list(9, 10), 2, 1)
CompareTrees(tree1, tree2)
identical(tree1, tree2)
## The trees are "equivalent" (notice the leaves 1 and 2 interchanged)
tree1 <- list(list(list(5, 6), list(7, 8), 3, 4), list(9, 10), 2, 1)
tree2 <- list(list(list(5, 6), list(7, 8), 3, 4), list(9, 10), 1, 2)
CompareTrees(tree1, tree2)
identical(tree1, tree2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.