]> git.donarmstrong.com Git - ape.git/blob - R/unique.multiPhylo.R
current 2.1 release
[ape.git] / R / unique.multiPhylo.R
1 ## unique.multiPhylo.R (2007-11-16)
2
3 ##   Revomes Duplicate Trees from a List
4
5 ## Copyright 2007 Emmanuel Paradis
6
7 ## This file is part of the R-package `ape'.
8 ## See the file ../COPYING for licensing issues.
9
10 unique.multiPhylo <- function(x, incomparables = FALSE,
11                               use.edge.length = FALSE,
12                               use.tip.label = TRUE, ...)
13 {
14     n <- length(x)
15     keep <- !logical(n)
16     for (i in 2:n) {
17         j <- 1
18         while (j < i) {
19             if (all.equal(x[[j]], x[[i]],
20                           use.edge.length = use.edge.length,
21                           use.tip.label = use.tip.label)) {
22                 keep[i] <- FALSE
23                 break
24             }
25             j <- j + 1
26         }
27     }
28     structure(x[keep], class = "multiPhylo")
29 }