]> git.donarmstrong.com Git - ape.git/blob - R/unique.multiPhylo.R
final commit for ape 3.0-8
[ape.git] / R / unique.multiPhylo.R
1 ## unique.multiPhylo.R (2008-06-09)
2
3 ##   Revomes Duplicate Trees from a List
4
5 ## Copyright 2007-2008 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 <- 1L
16     for (i in 2:n) {
17         already.seen <- FALSE
18         for (s in x[keep]) {
19             if (all.equal(s, x[[i]],
20                           use.edge.length = use.edge.length,
21                           use.tip.label = use.tip.label)) {
22                 already.seen <- TRUE
23                 break
24             }
25         }
26         if (!already.seen) keep <- c(keep, i)
27     }
28     x[keep]
29 }