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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 28 11:04:53 CET 2014


Author: jarioksa
Date: 2014-03-28 11:04:53 +0100 (Fri, 28 Mar 2014)
New Revision: 2866

Modified:
   pkg/vegan/R/fitted.radfit.R
   pkg/vegan/R/radfit.data.frame.R
   pkg/vegan/inst/ChangeLog
Log:
radfit plots work for sites with one or no species

Modified: pkg/vegan/R/fitted.radfit.R
===================================================================
--- pkg/vegan/R/fitted.radfit.R	2014-03-23 20:01:12 UTC (rev 2865)
+++ pkg/vegan/R/fitted.radfit.R	2014-03-28 10:04:53 UTC (rev 2866)
@@ -1,7 +1,13 @@
 `fitted.radfit` <-
     function(object, ...)
 {
-    sapply(object$models, fitted)
+    out <- sapply(object$models, fitted)
+    if (!length(object$y))
+        out <- numeric(length(object$models))
+    if (length(object$y) <= 1) 
+        out <- structure(as.vector(out), dim = c(1, length(object$models)),
+                         dimnames = list(names(object$y), names(object$models)))
+    out
 }
 
 `fitted.radfit.frame` <-

Modified: pkg/vegan/R/radfit.data.frame.R
===================================================================
--- pkg/vegan/R/radfit.data.frame.R	2014-03-23 20:01:12 UTC (rev 2865)
+++ pkg/vegan/R/radfit.data.frame.R	2014-03-28 10:04:53 UTC (rev 2866)
@@ -3,6 +3,12 @@
 {
     ## x *must* have rownames
     rownames(x) <- rownames(x, do.NULL = TRUE)
+    ## remove empty rows with no species
+    nspec <- specnumber(x)
+    if (any(nspec == 0)) {
+        warning("removed empty rows with no species")
+        x <- x[nspec>0,, drop=FALSE]
+    }
     out <- apply(x, 1, radfit, ...)
     if (length(out) == 1)
         out <- out[[1]]

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2014-03-23 20:01:12 UTC (rev 2865)
+++ pkg/vegan/inst/ChangeLog	2014-03-28 10:04:53 UTC (rev 2866)
@@ -51,6 +51,12 @@
 	with three points was reported by Paul Bacquet (Louvain,
 	Belgium). 
 
+	* radfit: plotting of radfit frames of several communuties failed
+	if there were one-species or no-species (empty) rows. Part of this
+	was fitted.radfit that now returns sensible and consistent output
+	for these cases as well, and radfit.data.frame() completely
+	removes empty rows from the data (with a warning).
+
 	* tabasco: "hclust" objects (use, sp.ind) are reordered using
 	weighted means. This is a better method than the unweighted means
 	used for reordering of dendrograms. Earlier "hclust" objects were



More information about the Vegan-commits mailing list