[Vegan-commits] r2811 - in branches/2.0: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Dec 8 08:44:19 CET 2013


Author: jarioksa
Date: 2013-12-08 08:44:18 +0100 (Sun, 08 Dec 2013)
New Revision: 2811

Modified:
   branches/2.0/R/envfit.default.R
   branches/2.0/R/factorfit.R
   branches/2.0/R/vectorfit.R
   branches/2.0/inst/ChangeLog
Log:
merge 2810 to vegan 2.0-10 (2809 escaped in previous commit)

Modified: branches/2.0/R/envfit.default.R
===================================================================
--- branches/2.0/R/envfit.default.R	2013-12-08 07:36:14 UTC (rev 2810)
+++ branches/2.0/R/envfit.default.R	2013-12-08 07:44:18 UTC (rev 2811)
@@ -17,13 +17,9 @@
         na.action <- structure(seq_along(keep)[!keep], class="omit")
     }
     if (is.data.frame(env)) {
-        facts <- sapply(env, is.factor)
         vects <- sapply(env, is.numeric)
-        if (!all(facts | vects))
-            warning("the following variables are ignored because they are neither numeric nor factors:\n",
-                    paste(colnames(env)[!(facts | vects)], collapse=", "))
-        if (sum(facts)) {  # have factors
-            Pfac <- env[, facts, drop = FALSE]
+        if (any(!vects)) {  # have factors
+            Pfac <- env[, !vects, drop = FALSE]
             P <- env[, vects, drop = FALSE]
             if (length(P)) {
                 if (permutations) {

Modified: branches/2.0/R/factorfit.R
===================================================================
--- branches/2.0/R/factorfit.R	2013-12-08 07:36:14 UTC (rev 2810)
+++ branches/2.0/R/factorfit.R	2013-12-08 07:44:18 UTC (rev 2811)
@@ -2,9 +2,13 @@
     function (X, P, permutations = 0, strata, w,  ...) 
 {
     P <- as.data.frame(P)
+    ## Check that all variables are factors, and coerce if necessary
+    if(any(!sapply(P, is.factor)))
+        P <- data.frame(lapply(P, function(x)
+                        if (is.factor(x)) x else factor(x)))
     P <- droplevels(P) ## make sure only the used levels are present
     if (any(!sapply(P, is.factor))) 
-        stop("All fitted variables must be factors")
+        stop("All non-numeric variables must be factors")
     NR <- nrow(X)
     NC <- ncol(X)
     NF <- ncol(P)

Modified: branches/2.0/R/vectorfit.R
===================================================================
--- branches/2.0/R/vectorfit.R	2013-12-08 07:36:14 UTC (rev 2810)
+++ branches/2.0/R/vectorfit.R	2013-12-08 07:44:18 UTC (rev 2811)
@@ -37,7 +37,7 @@
             Hperm <- qr.fitted(Q, take)
             permstore[i, ] <- diag(cor(Hperm, take))^2
         }
-        permstore <- sweep(permstore, 2, r, ">")
+        permstore <- sweep(permstore, 2, r, ">=")
         pvals <- (apply(permstore, 2, sum) + 1)/(permutations + 1)
     }
     else pvals <- NULL

Modified: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog	2013-12-08 07:36:14 UTC (rev 2810)
+++ branches/2.0/inst/ChangeLog	2013-12-08 07:44:18 UTC (rev 2811)
@@ -3,7 +3,9 @@
 VEGAN RELEASE VERSIONS at http://cran.r-project.org/
 
 Version 2.0-10 (opened December 5, 2013)
-
+	
+	* merge 2809,2810: treat all non-numeric variables as factors
+	inenvfit.
 	* merge 2713 man/: remove references to very old R versions in man
 	files (R/ part of this rev not applied)
 	* merge 2708: adapt quantilesto test direction.



More information about the Vegan-commits mailing list