X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fidentify.phylo.R;h=130a8788c658b35471af23895981068e9d622e58;hb=bfaeca35ec130110327a3bb7a1f0fe3b66076a95;hp=108f03e4a37ee547329f7d85e59d082425e86cf6;hpb=1d0651b1374592d87400614a03b34b4e0cc63aae;p=ape.git diff --git a/R/identify.phylo.R b/R/identify.phylo.R index 108f03e..130a878 100644 --- a/R/identify.phylo.R +++ b/R/identify.phylo.R @@ -1,4 +1,4 @@ -## identify.phylo.R (2008-02-08) +## identify.phylo.R (2008-02-28) ## Graphical Identification of Nodes and Tips @@ -12,22 +12,21 @@ identify.phylo <- function(x, nodes = TRUE, tips = FALSE, { cat("Click close to a node of the tree...\n") xy <- locator(1) - Ntip <- get("last_plot.phylo$Ntip", envir = .PlotPhyloEnv) - d <- sqrt((xy$x - get("last_plot.phylo$xx", envir = .PlotPhyloEnv))^2 + - (xy$y - get("last_plot.phylo$yy", envir = .PlotPhyloEnv))^2) + lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv) + d <- sqrt((xy$x - lastPP$xx)^2 + (xy$y - lastPP$yy)^2) NODE <- which.min(d) res <- list() - if (NODE <= Ntip) { + if (NODE <= lastPP$Ntip) { res$tips <- if (labels) x$tip.label[NODE] else NODE return(res) } if (tips) { - TIPS <- prop.part(x)[[NODE - Ntip]] + TIPS <- prop.part(x)[[NODE - lastPP$Ntip]] res$tips <- if (labels) x$tip.label[TIPS] else TIPS } if (nodes) { if (is.null(x$node.label)) labels <- FALSE - res$nodes <- if (labels) x$node.label[NODE - Ntip] else NODE + res$nodes <- if (labels) x$node.label[NODE - lastPP$Ntip] else NODE } res }