[Vegan-commits] r506 - in pkg: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 26 12:54:07 CEST 2008


Author: jarioksa
Date: 2008-09-26 12:54:06 +0200 (Fri, 26 Sep 2008)
New Revision: 506

Modified:
   pkg/R/treedive.R
   pkg/inst/NEWS
Log:
treedive: improved matching of tree and comm names

Modified: pkg/R/treedive.R
===================================================================
--- pkg/R/treedive.R	2008-09-26 10:47:43 UTC (rev 505)
+++ pkg/R/treedive.R	2008-09-26 10:54:06 UTC (rev 506)
@@ -6,6 +6,10 @@
     m <- as.matrix(cophenetic(tree))
     ## Check tree/comm match by names
     if (match.force || ncol(comm) != length(tree$order)) {
+        if (match.force)
+            message("Forced matching of 'tree' labels and 'comm' names")
+        else
+            message("Dimensions do not match between 'comm' and 'tree'")
         fnd <- colnames(comm) %in% tree$labels
         if (!all(fnd)) {
             warning("not all names of 'comm' found in 'tree'")
@@ -15,6 +19,10 @@
         if (!all(fnd))
             warning("not all names of 'tree' found in 'comm'")
         comm <- comm[, tree$labels[fnd]]
+        if (length(unique(tree$labels)) != length(tree$labels))
+            stop("names not unique in 'tree': match wrong")
+        if (length(unique(colnames(comm))) != ncol(comm))
+            stop("names not unique in 'comm': match wrong")
     }
     ## Repeat for sites
     div <- numeric(nrow(comm))
@@ -27,4 +35,3 @@
     names(div) <- rownames(comm)
     div
 }
-

Modified: pkg/inst/NEWS
===================================================================
--- pkg/inst/NEWS	2008-09-26 10:47:43 UTC (rev 505)
+++ pkg/inst/NEWS	2008-09-26 10:54:06 UTC (rev 506)
@@ -36,7 +36,6 @@
       height of dendrogram of species properties (Petchey & Gaston,
       Ecology Letters 9, 741-758; 2006). With a helper function
       'treeheight' to find the height of a 'hclust' dendrogram.
-      FIXME: check matching names in dendrogram and community data.
 
     - tsallis: Tsallis entropy family as an alternative to 'renyi'. 
 



More information about the Vegan-commits mailing list