X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fnj.R;h=dada70e52a2a63b20777f98a6bee4ecfab65320e;hb=90f18c75d642f56b020bc6e0cdd0c5949c1d9a1d;hp=6f60d8ec8b7d9bd53c16d983f2850e40289d80bf;hpb=100e0d086372a87bc2506873bdf86d3fcdda9922;p=ape.git diff --git a/R/nj.R b/R/nj.R index 6f60d8e..dada70e 100644 --- a/R/nj.R +++ b/R/nj.R @@ -1,4 +1,4 @@ -## nj.R (2009-07-10) +## nj.R (2009-11-23) ## Neighbor-Joining Tree Estimation @@ -10,12 +10,14 @@ nj <- function(X) { if (is.matrix(X)) X <- as.dist(X) + if (any(is.na(X))) + stop("missing values are not allowed in the distance matrix") N <- attr(X, "Size") labels <- attr(X, "Labels") if (is.null(labels)) labels <- as.character(1:N) ans <- .C("nj", as.double(X), as.integer(N), integer(2*N - 3), integer(2*N - 3), double(2*N - 3), - DUP = FALSE, NAOK = TRUE, PACKAGE = "apex") + DUP = FALSE, NAOK = TRUE, PACKAGE = "ape") obj <- list(edge = cbind(ans[[3]], ans[[4]]), edge.length = ans[[5]], tip.label = labels, Nnode = N - 2L) class(obj) <- "phylo"