]> git.donarmstrong.com Git - ape.git/blobdiff - R/bind.tree.R
some changes done before the HD failure of my laptop... I presume
[ape.git] / R / bind.tree.R
index 58d7caba4a4a9831652ea6a159d976cb8b07c87f..b43ce900055d4c393e324023ab7ff57801a0afe8 100644 (file)
@@ -1,8 +1,8 @@
-## bind.tree.R (2011-03-02)
+## bind.tree.R (2012-02-13)
 
 ##    Bind Trees
 
-## Copyright 2003-2011 Emmanuel Paradis
+## Copyright 2003-2012 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -63,9 +63,11 @@ bind.tree <- function(x, y, where = "root", position = 0, interactive = FALSE)
     ## case = 3 -> y is bound on a node of x
 
     ## check that 'position' is correct
-    if (position) {
-        if (!wbl)
-            stop("'position' is non-null but trees have no branch lengths")
+    if (position && wbl) {
+### New in ape 3.0-1: this makes possible binding 'y' below
+### a node of 'x' thus creating a new node in 'x'
+###        if (!wbl)
+###            stop("'position' is non-null but trees have no branch lengths")
         if (case == 1) {
             if (xHasNoRootEdge)
                 stop("tree 'x' has no root edge")
@@ -146,8 +148,8 @@ bind.tree <- function(x, y, where = "root", position = 0, interactive = FALSE)
                 y$edge[1] <- x$edge[i, 1]
                 ## delete i-th edge in x:
                 x$edge <- x$edge[-i, ]
-                i <- i - 1L
                 if (wbl) x$edge.length <- x$edge.length[-i]
+                i <- i - 1L
             }
             x$tip.label <- x$tip.label[-where]
             ## renumber the tips that need to: