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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 29 10:17:16 CET 2013


Author: jarioksa
Date: 2013-01-29 10:17:15 +0100 (Tue, 29 Jan 2013)
New Revision: 2394

Modified:
   pkg/vegan/R/oecosimu.R
   pkg/vegan/inst/ChangeLog
Log:
oecosimu gave an error or a mess if nestfun() returned a data frame

Modified: pkg/vegan/R/oecosimu.R
===================================================================
--- pkg/vegan/R/oecosimu.R	2013-01-28 14:20:54 UTC (rev 2393)
+++ pkg/vegan/R/oecosimu.R	2013-01-29 09:17:15 UTC (rev 2394)
@@ -6,6 +6,8 @@
 {
     alternative <- match.arg(alternative)
     nestfun <- match.fun(nestfun)
+    if (length(statistic) > 1)
+        stop("only one 'statistic' is allowed")
     applynestfun <-
         function(x, fun = nestfun, statistic = "statistic", ...) {
             tmp <- fun(x, ...)
@@ -119,8 +121,12 @@
     if (any(is.na(z)))
         p[is.na(z)] <- NA
 
-    if (is.null(names(indstat)))
+    if (is.null(names(indstat)) && length(indstat) == 1)
         names(indstat) <- statistic
+    ## $oecosimu cannot be added to a data frame, but this gives
+    ## either an error or a mess
+    if (is.data.frame(ind))
+        ind <- as.list(ind)
     if (!is.list(ind))
         ind <- list(statistic = ind)
     ind$oecosimu <- list(z = z, means = means, pval = p, simulated=simind,

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2013-01-28 14:20:54 UTC (rev 2393)
+++ pkg/vegan/inst/ChangeLog	2013-01-29 09:17:15 UTC (rev 2394)
@@ -4,6 +4,20 @@
 
 Version 2.1-24 (opened January 25, 2013)
 
+	* oecosimu: the 'oecosimu' list cannot be added to the result if
+	the nestfun() returns a data frame. In that case, the 'oecosimu'
+	list is treated like a variable, and this gives either an error of
+	wrong length or if the length matches, a mess.  Now data frame is
+	silently turned into a list which also means that it will not be
+	printed with the output. The name of the 'statistic' is not used
+	for unnamed vector output where it would only name the first item
+	(like would be the case if the 'statistic' was extracted from a
+	data frame). It is now checked that only one 'statistic' is given
+	and a comprehensible error message is issued instead of the
+	current confusing one. The changes were trickered in an attempt to
+	use picante::pd(), but this still fails because picante::pd()
+	needs column names that are not generated in nullmodel(). 
+
 	* protest: huge speed-up. Instead of calling procrustes() in every
 	permutation step, we only calculate the goodness of fit statistic
 	in svd(). This avoids a huge overhead of procrustes(). In a test



More information about the Vegan-commits mailing list