[Vegan-commits] r1544 - pkg/vegan/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 16 16:29:02 CET 2011


Author: jarioksa
Date: 2011-03-16 16:29:02 +0100 (Wed, 16 Mar 2011)
New Revision: 1544

Modified:
   pkg/vegan/R/metaMDSrotate.R
Log:
use vectorfit instead of envfit, fix error message and check for numeric 'vec'

Modified: pkg/vegan/R/metaMDSrotate.R
===================================================================
--- pkg/vegan/R/metaMDSrotate.R	2011-03-16 10:00:32 UTC (rev 1543)
+++ pkg/vegan/R/metaMDSrotate.R	2011-03-16 15:29:02 UTC (rev 1544)
@@ -11,7 +11,9 @@
         stop(gettextf("needs at least 2 dimensions"))
     vec <- drop(vec)
     if (length(dim(vec)) > 1)
-        stop(gettextf, "function works only with univariate 'vec'")
+        stop(gettextf("function works only with univariate 'vec'"))
+    if (!is.numeric(vec))
+        stop(gettextf("'vec' must be numeric"))
     ## scores must be orthogonal for the next loop to work
     if (N > 2) {
         pc <- prcomp(x)
@@ -23,7 +25,7 @@
     ## 'vec' which means that we make other axes orthogonal to 'vec'
     ## one by one
     for (k in 2:N) {
-        rot <- envfit(x, vec, choices = c(1,k), permutations=0)$vectors$arrows
+        rot <- vectorfit(x[, c(1,k)], vec, permutations=0)$arrows
         rot <- drop(rot)
         ## rotation matrix [[sin theta, cos theta] [-cos theta, sin theta]]
         rot <- rbind(rot, rev(rot))



More information about the Vegan-commits mailing list