X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fidentify.phylo.R;h=130a8788c658b35471af23895981068e9d622e58;hb=188a8123d039d442dacb35ae678729375e22d239;hp=46ab427458398c59afd37ccaf53c5852930986ac;hpb=c827059eeafc8cbe41c812b26979543ab287803e;p=ape.git diff --git a/R/identify.phylo.R b/R/identify.phylo.R index 46ab427..130a878 100644 --- a/R/identify.phylo.R +++ b/R/identify.phylo.R @@ -1,8 +1,8 @@ -## identify.phylo.R (2007-12-14) +## identify.phylo.R (2008-02-28) ## Graphical Identification of Nodes and Tips -## Copyright 2007 Emmanuel Paradis +## Copyright 2008 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -10,24 +10,23 @@ identify.phylo <- function(x, nodes = TRUE, tips = FALSE, labels = FALSE, ...) { + cat("Click close to a node of the tree...\n") xy <- locator(1) - Ntip <- .last_plot.phylo$Ntip - d <- sqrt((xy$x - .last_plot.phylo$xx)^2 + - (xy$y - .last_plot.phylo$yy)^2) + lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv) + d <- sqrt((xy$x - lastPP$xx)^2 + (xy$y - lastPP$yy)^2) NODE <- which.min(d) - print(NODE) 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 }