[Vegan-commits] r2809 - in pkg/vegan: R inst
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Dec 6 19:37:41 CET 2013
Author: jarioksa
Date: 2013-12-06 19:37:41 +0100 (Fri, 06 Dec 2013)
New Revision: 2809
Modified:
pkg/vegan/R/envfit.default.R
pkg/vegan/inst/ChangeLog
Log:
envift does not choke on character variables but ignores them (with a warning)
Modified: pkg/vegan/R/envfit.default.R
===================================================================
--- pkg/vegan/R/envfit.default.R 2013-12-05 12:34:46 UTC (rev 2808)
+++ pkg/vegan/R/envfit.default.R 2013-12-06 18:37:41 UTC (rev 2809)
@@ -1,4 +1,4 @@
-"envfit.default" <-
+`envfit.default` <-
function (ord, env, permutations = 999, strata, choices = c(1, 2),
display = "sites", w = weights(ord), na.rm = FALSE, ...)
{
@@ -32,9 +32,13 @@
}
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]
- P <- env[, !facts, drop = FALSE]
+ P <- env[, vects, drop = FALSE]
if (length(P)) { # also have vectors
vectors <- vectorfit(X, P, permutations, strata,
choices, w = w, ...)
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2013-12-05 12:34:46 UTC (rev 2808)
+++ pkg/vegan/inst/ChangeLog 2013-12-06 18:37:41 UTC (rev 2809)
@@ -20,6 +20,15 @@
adapted to new anova.cca and this brought along similar changes in
API.
+ * envfit: function assumed that environmental variables are either
+ factors or numeric, and choked if they were neither but, say,
+ character strings. Now the function ignores variables which are
+ neither factors nor numeric (with a warning). This is one possible
+ reason for problems reported in
+ https://stat.ethz.ch/pipermail/r-sig-ecology/2013-December/004217.html,
+ although the reported case is irreproducible and we cannot be
+ sure.
+
* tests for cca/rda/capscale: commented out test that failed with
the anova.cca. Known issue was that 'by = "term"' and 'by =
"axis"' stop with error with missing data. This was designed and
More information about the Vegan-commits
mailing list