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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 10 15:43:09 CEST 2011


Author: jarioksa
Date: 2011-10-10 15:43:09 +0200 (Mon, 10 Oct 2011)
New Revision: 1944

Modified:
   pkg/vegan/R/capscale.R
   pkg/vegan/R/rda.default.R
   pkg/vegan/R/simulate.rda.R
   pkg/vegan/inst/ChangeLog
Log:
sd() for matrices was deprecated in R rev57185: vegan adapts

Modified: pkg/vegan/R/capscale.R
===================================================================
--- pkg/vegan/R/capscale.R	2011-10-10 06:13:03 UTC (rev 1943)
+++ pkg/vegan/R/capscale.R	2011-10-10 13:43:09 UTC (rev 1944)
@@ -111,7 +111,7 @@
     }
     if (!is.null(comm)) {
         comm <- scale(comm, center = TRUE, scale = FALSE)
-        sol$colsum <- sd(comm)
+        sol$colsum <- apply(comm, 2, sd)
         ## take a 'subset' of the community after scale()
         if (!is.null(d$subset))
             comm <- comm[d$subset, , drop = FALSE]

Modified: pkg/vegan/R/rda.default.R
===================================================================
--- pkg/vegan/R/rda.default.R	2011-10-10 06:13:03 UTC (rev 1943)
+++ pkg/vegan/R/rda.default.R	2011-10-10 13:43:09 UTC (rev 1944)
@@ -8,7 +8,7 @@
     X <- as.matrix(X)
     NR <- nrow(X) - 1
     Xbar <- scale(X, center = TRUE, scale = scale)
-    SD <- sd(Xbar)
+    SD <- apply(Xbar, 2, sd)
     if (scale) 
         Xbar[is.nan(Xbar)] <- 0
     tot.chi <- sum(svd(Xbar, nu = 0, nv = 0)$d^2)/NR

Modified: pkg/vegan/R/simulate.rda.R
===================================================================
--- pkg/vegan/R/simulate.rda.R	2011-10-10 06:13:03 UTC (rev 1943)
+++ pkg/vegan/R/simulate.rda.R	2011-10-10 13:43:09 UTC (rev 1944)
@@ -38,7 +38,7 @@
     for (i in seq_len(nsim)) {
         if (is.null(indx))
             ans[,,i] <- as.matrix(ftd + matrix(rnorm(length(ftd), 
-               sd = outer(rep(1,nrow(ftd)), sd(object$CA$Xbar))), 
+               sd = outer(rep(1,nrow(ftd)), apply(object$CA$Xbar, 2, sd))), 
                nrow = nrow(ftd)))
         else
             ans[,,i] <- as.matrix(ftd + object$CA$Xbar[indx[i,],])
@@ -110,8 +110,8 @@
     for (i in seq_len(nsim)) {
         if (is.null(indx)) {
             tmp <- matrix(rnorm(length(ftd), 
-               sd = outer(rep(1,nrow(ftd)), sd(Xbar))), 
-               nrow = nrow(ftd))
+               sd = outer(rep(1,nrow(ftd)), apply(Xbar, 2, sd))), 
+                          nrow = nrow(ftd))
             ans[,,i] <- as.matrix(ftd + sweep(tmp, 1, sq.r, "/"))
         }
         else 
@@ -191,7 +191,7 @@
         ftd <- ftd + object$pCCA$Fit
     if (is.null(indx))
         ans <- as.data.frame(ftd + matrix(rnorm(length(ftd), 
-               sd = outer(rep(1,nrow(ftd)), sd(object$CA$Xbar))), 
+               sd = outer(rep(1,nrow(ftd)), apply(object$CA$Xbar, 2, sd))), 
                nrow = nrow(ftd)))
     else
         ans <- ftd + object$CA$Xbar[indx,]

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2011-10-10 06:13:03 UTC (rev 1943)
+++ pkg/vegan/inst/ChangeLog	2011-10-10 13:43:09 UTC (rev 1944)
@@ -4,6 +4,14 @@
 
 Version 2.1-3 (opened October 4, 2011)
 
+	* sd() function for matrix or data.frame columns was deprecated in
+	R r57185 (R-to-be-2.15.0). The reason seems to be that users were
+	confused when median() did not work on data.frames, and as a
+	solution the R developers decided to take care that mean() or sd()
+	will not work either (it would be nice to understand how these
+	people think). Fixed in rda.default, capscale and
+	simulate.rda/cca/capscale.
+
 	* nesteddisc: use only max 200 tries to reorder columns: tracing
 	showed that in most cases an improved ordering is found rather
 	quickly, and trying up to 1000 times takes awfully long. Now



More information about the Vegan-commits mailing list