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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 18 16:29:45 CEST 2009


Author: jarioksa
Date: 2009-09-18 16:29:44 +0200 (Fri, 18 Sep 2009)
New Revision: 1013

Modified:
   pkg/vegan/R/ordiParseFormula.R
   pkg/vegan/inst/ChangeLog
Log:
cca/rda/capscale ran into trouble with 1-level factors generated by 'subset' & 'na.action'

Modified: pkg/vegan/R/ordiParseFormula.R
===================================================================
--- pkg/vegan/R/ordiParseFormula.R	2009-09-18 13:05:36 UTC (rev 1012)
+++ pkg/vegan/R/ordiParseFormula.R	2009-09-18 14:29:44 UTC (rev 1013)
@@ -52,6 +52,10 @@
         mf <- model.frame(formula(mf), mf, xlev = xlev,
                           na.action = na.action, drop.unused.levels = TRUE)
         nas <- attr(mf, "na.action")
+        ## Check if there are one-level factors after subset and na.action
+        for (i in 1:ncol(mf))
+            if (is.factor(mf[[i]]) && length(levels(mf[[i]])) <= 1)
+                mf[[i]] <- as.numeric(mf[[i]])
     } else {
         nas <- NULL
     }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-09-18 13:05:36 UTC (rev 1012)
+++ pkg/vegan/inst/ChangeLog	2009-09-18 14:29:44 UTC (rev 1013)
@@ -19,9 +19,11 @@
 	looking at the 'data' (and the 'data' arg is now unused in
 	'ordiTerminfo'). 
 
-	* FIXME: cca(dune ~ Management, dune.env, subset = Management ==
-	"SF") fails in 'contrasts()' called from 'model.matrix()' because
-	there is only one level in Management.
+	* FIXED (minor): cca(dune ~ Management, dune.env, subset =
+	Management == "SF") failed in 'contrasts()' called from
+	'model.matrix()' because there is only one level in Management.
+	Now 'ordiParseFormula' changes one-level factors into numeric() so
+	that they are cleanly(?) aliased.
 	
 Version 1.16-29 (closed September 18, 2009)
 



More information about the Vegan-commits mailing list