X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fdrop.tip.R;h=a4a3d030207f2baa34d5a63ef535826fd11bce27;hb=8583b8f50f7747a557dbaf6678207da5108087f9;hp=efa429af446223f5838cfe58930d9bed17fc2395;hpb=7e78dcfcf1bca3d6aaca7ae92ab0f4fb3d9cc711;p=ape.git diff --git a/R/drop.tip.R b/R/drop.tip.R index efa429a..a4a3d03 100644 --- a/R/drop.tip.R +++ b/R/drop.tip.R @@ -96,24 +96,23 @@ drop.tip <- ## find the tips to drop: if (is.character(tip)) tip <- which(phy$tip.label %in% tip) - trms <- edge2 <= Ntip ## delete the terminal edges given by `tip': keep[match(tip, edge2)] <- FALSE if (trim.internal) { - ## delete the internal edges that do not have descendants - ## anymore (ie, they are in the 2nd column of `edge' but + internals <- edge2 <= Ntip + ## delete the internal edges that do not have anymore + ## descendants (ie, they are in the 2nd col of `edge' but ## not in the 1st one) repeat { - sel <- !(edge2 %in% edge1[keep]) & !trms & keep + sel <- !(edge2 %in% edge1[keep]) & internals & keep if (!sum(sel)) break keep[sel] <- FALSE } if (subtree) { ## keep the subtending edge(s): subt <- edge1 %in% edge1[keep] & edge1 %in% edge1[!keep] - ## 'if (... ' needed below? - if (any(subt)) keep[which(subt)] <- TRUE + keep[subt] <- TRUE } if (root.edge && wbl) { degree <- tabulate(edge1[keep])