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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 20 13:34:08 CEST 2009


Author: jarioksa
Date: 2009-09-20 13:34:07 +0200 (Sun, 20 Sep 2009)
New Revision: 1014

Modified:
   pkg/vegan/R/ordiParseFormula.R
   pkg/vegan/inst/ChangeLog
Log:
better fix for 1-level factors in cca/rda/capscale

Modified: pkg/vegan/R/ordiParseFormula.R
===================================================================
--- pkg/vegan/R/ordiParseFormula.R	2009-09-18 14:29:44 UTC (rev 1013)
+++ pkg/vegan/R/ordiParseFormula.R	2009-09-20 11:34:07 UTC (rev 1014)
@@ -55,7 +55,7 @@
         ## 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]])
+                levels(mf[[i]]) <- c(levels(mf[[i]]), ".ThisVarHasOnly1Level")
     } else {
         nas <- NULL
     }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-09-18 14:29:44 UTC (rev 1013)
+++ pkg/vegan/inst/ChangeLog	2009-09-20 11:34:07 UTC (rev 1014)
@@ -22,8 +22,10 @@
 	* 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.
+	Now 'ordiParseFormula' adds a level with an unlikely name of
+	.ThisVarHasOnly1Level, so that model.matrix works, but
+	predict.cca(..., newdata=, type = "lc") rejects unknown factor
+	levels.
 	
 Version 1.16-29 (closed September 18, 2009)
 



More information about the Vegan-commits mailing list