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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 2 08:20:32 CEST 2012


Author: jarioksa
Date: 2012-09-02 08:20:32 +0200 (Sun, 02 Sep 2012)
New Revision: 2262

Modified:
   pkg/vegan/R/mantel.R
   pkg/vegan/R/mantel.partial.R
   pkg/vegan/inst/ChangeLog
Log:
do not mix cor() and cor.test() in mantel(.partial)

Modified: pkg/vegan/R/mantel.R
===================================================================
--- pkg/vegan/R/mantel.R	2012-08-31 04:33:21 UTC (rev 2261)
+++ pkg/vegan/R/mantel.R	2012-09-02 06:20:32 UTC (rev 2262)
@@ -4,9 +4,13 @@
 {
     xdis <- as.dist(xdis)
     ydis <- as.vector(as.dist(ydis))
-    tmp <- cor.test(as.vector(xdis), ydis, method = method)
-    statistic <- as.numeric(tmp$estimate)
-    variant <- tmp$method
+    statistic <- cor(as.vector(xdis), ydis, method = method)
+    variant <- match.arg(method, eval(formals(cor)$method))
+    variant <- switch(variant,
+                      pearson = "Pearson's product-moment correlation",
+                      kendall = "Kendall's rank correlation tau",
+                      spearman = "Spearman's rank correlation rho",
+                      variant)
     N <- attr(xdis, "Size")
     if (length(permutations) == 1) {
         if (permutations > 0) {

Modified: pkg/vegan/R/mantel.partial.R
===================================================================
--- pkg/vegan/R/mantel.partial.R	2012-08-31 04:33:21 UTC (rev 2261)
+++ pkg/vegan/R/mantel.partial.R	2012-09-02 06:20:32 UTC (rev 2262)
@@ -8,11 +8,15 @@
     xdis <- as.dist(xdis)
     ydis <- as.vector(as.dist(ydis))
     zdis <- as.vector(as.dist(zdis))
-    rxy <- cor.test(as.vector(xdis), ydis, method = method)
+    rxy <- cor(as.vector(xdis), ydis, method = method)
     rxz <- cor(as.vector(xdis), zdis, method = method)
     ryz <- cor(ydis, zdis, method = method)
-    variant <- rxy$method
-    rxy <- rxy$estimate
+    variant <- match.arg(method, eval(formals(cor)$method))
+    variant <- switch(variant,
+                      pearson = "Pearson's product-moment correlation",
+                      kendall = "Kendall's rank correlation tau",
+                      spearman = "Spearman's rank correlation rho",
+                      variant)
     statistic <- part.cor(rxy, rxz, ryz)
     N <- attr(xdis, "Size")
     if (length(permutations) == 1) {

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-08-31 04:33:21 UTC (rev 2261)
+++ pkg/vegan/inst/ChangeLog	2012-09-02 06:20:32 UTC (rev 2262)
@@ -42,6 +42,11 @@
 	oecosimu-compliant earlier and simultaneously they also gained the
 	density and densityplot methods.
 
+	* mantel, mantel.partial: mixed cor.test() and cor(), but now only
+	use cor(). The use of cor.test() was only used to get the textual
+	presentation of the correlation 'method'. Internal changes that
+	should have no effect in results, but consistency is a good thing.
+
 	* protest: do not return the observed statistic as one of the
 	permuted values but separately.
 	



More information about the Vegan-commits mailing list