[Vegan-commits] r1329 - in pkg/vegan: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 12 20:15:07 CEST 2010


Author: jarioksa
Date: 2010-10-12 20:15:06 +0200 (Tue, 12 Oct 2010)
New Revision: 1329

Modified:
   pkg/vegan/R/treedive.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/treedive.Rd
Log:
treedive handles trivial cases of one and zero species communities

Modified: pkg/vegan/R/treedive.R
===================================================================
--- pkg/vegan/R/treedive.R	2010-10-05 15:58:02 UTC (rev 1328)
+++ pkg/vegan/R/treedive.R	2010-10-12 18:15:06 UTC (rev 1329)
@@ -28,9 +28,17 @@
     div <- numeric(nrow(comm))
     for (i in 1:nrow(comm)) {
         k <- comm[i,] > 0
-        d <- as.dist(m[k,k])
-        cl <- update(tree, d = d)
-        div[i] <- treeheight(cl)
+        nit <- sum(k)
+        ## Trivial cases of zero or one species
+        if (nit==0)
+            div[i] <- NA
+        else if (nit==1)
+            div[i] <- 0
+        else {
+            d <- as.dist(m[k,k])
+            cl <- update(tree, d = d)
+            div[i] <- treeheight(cl)
+        }
     }
     names(div) <- rownames(comm)
     div

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-10-05 15:58:02 UTC (rev 1328)
+++ pkg/vegan/inst/ChangeLog	2010-10-12 18:15:06 UTC (rev 1329)
@@ -4,6 +4,9 @@
 
 Version 1.18-13 (opened September 26, 2010)
 
+	* treedive: handles trivial cases of zero (diversity NA) or one
+	species (diversity 0). 
+
 	* nestednodf: Gustavo Carvalho sent a new upgraded version which
 	also implements a new quantitative method of Almeida-Neto & Ulrich
 	(Env Mod Software, in press; 2010). Based on feature request #1097
@@ -16,10 +19,10 @@
 	fit to random species accumulation and sent his model function.
 	These ideas were used to add a new more general function. In
 	addition, there is an option of fitting Arrhenius model S = c*A^z
-	with a new self stargint function SSarrhenius() for nls(). No
+	with a new self starting function SSarrhenius() for nls(). No
 	documentation yet: needs work.
 
-	* decorana: gives warning if residual is bigger than tolerance.
+	* decorana: gives a warning if residual is bigger than tolerance.
 	
 Version 1.18-12 (closed September 26, 2010)
 

Modified: pkg/vegan/man/treedive.Rd
===================================================================
--- pkg/vegan/man/treedive.Rd	2010-10-05 15:58:02 UTC (rev 1328)
+++ pkg/vegan/man/treedive.Rd	2010-10-12 18:15:06 UTC (rev 1329)
@@ -35,13 +35,15 @@
   2002, 2006).
 
   Function \code{treedive} finds the \code{treeheight} for each site
-  (row) of a community matrix. The function uses a subset of dendrogram
-  for those species that occur in each site, and excludes the tree root
-  if that is not needed to connect the species (Petchey and Gaston
-  2006). The subset of the dendrogram is found by first calculating
-  \code{\link{cophenetic}} distances from the input dendrogram, then
-  reconstructing the dendrogram for the subset of the cophenetic
-  distance matrix for species occurring in each site.
+  (row) of a community matrix. The function uses a subset of
+  dendrogram for those species that occur in each site, and excludes
+  the tree root if that is not needed to connect the species (Petchey
+  and Gaston 2006). The subset of the dendrogram is found by first
+  calculating \code{\link{cophenetic}} distances from the input
+  dendrogram, then reconstructing the dendrogram for the subset of the
+  cophenetic distance matrix for species occurring in each
+  site. Diversity is 0 for one spcies, and \code{NA} for empty
+  communities.
 
   Function \code{treedist} finds the dissimilarities among
   trees. Pairwise dissimilarity of two trees is found by combining



More information about the Vegan-commits mailing list