X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fdrop.tip.R;h=5b635f680f4459a579242dfc4fdf2c549d9b5f22;hb=d1546ec66ff1a8ea123adefebe14f6316c23705f;hp=948b2267b8e98a5bd5547b58fa4050f09b69d147;hpb=52008daf7f708f3fcdc735f22af308dd1a461670;p=ape.git diff --git a/R/drop.tip.R b/R/drop.tip.R index 948b226..5b635f6 100644 --- a/R/drop.tip.R +++ b/R/drop.tip.R @@ -1,8 +1,8 @@ -## drop.tip.R (2010-11-24) +## drop.tip.R (2011-11-21) ## Remove Tips in a Phylogenetic Tree -## Copyright 2003-2010 Emmanuel Paradis +## Copyright 2003-2011 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -54,7 +54,11 @@ extract.clade <- function(phy, node, root.edge = 0, interactive = FALSE) if (wbl) phy$edge.length <- phy$edge.length[keep] TIPS <- phy$edge[, 2] <= Ntip tip <- phy$edge[TIPS, 2] - phy$tip.label <- phy$tip.label[sort(tip)] # <- added sort to avoid shuffling of tip labels (2010-07-21) + ## Fix by Ludovic Mallet and Mahendra Mariadassou (2011-11-21): + name <- vector("character", length(tip)) + name[order(tip)] <- phy$tip.label[tip] + phy$tip.label <- name + ## End of fix ## keep the ordering so no need to reorder tip.label: phy$edge[TIPS, 2] <- order(tip) if (!is.null(phy$node.label)) @@ -79,6 +83,7 @@ drop.tip <- { if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"') + if (!length(tip)) return(phy) Ntip <- length(phy$tip.label) ## find the tips to drop: