[Vegan-commits] r1214 - pkg/vegan/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jun 3 20:20:05 CEST 2010
Author: gsimpson
Date: 2010-06-03 20:20:05 +0200 (Thu, 03 Jun 2010)
New Revision: 1214
Modified:
pkg/vegan/R/betadisper.R
Log:
spatial median computed now on real and imaginary axes seperately
Modified: pkg/vegan/R/betadisper.R
===================================================================
--- pkg/vegan/R/betadisper.R 2010-06-01 11:22:26 UTC (rev 1213)
+++ pkg/vegan/R/betadisper.R 2010-06-03 18:20:05 UTC (rev 1214)
@@ -1,6 +1,13 @@
`betadisper` <-
function(d, group, type = c("median","centroid"))
{
+ ## inline function for spatial medians
+ spatialMed <- function(vectors, group, pos) {
+ axes <- seq_len(NCOL(vectors))
+ spMedPos <- ordimedian(vectors, group, choices = axes[pos])
+ spMedNeg <- ordimedian(vectors, group, choices = axes[!pos])
+ return(cbind(spMedPos, spMedNeg))
+ }
## Tolerance for zero Eigenvalues
TOL <- 1e-7
## uses code from stats:::cmdscale by R Core Development Team
@@ -53,7 +60,7 @@
centroids <-
switch(type,
centroid = apply(vectors, 2, function(x) tapply(x, group, mean)),
- median = ordimedian(vectors, group, choices = 1:ncol(vectors))
+ median = spatialMed(vectors, group, pos)
)
## for each of the groups, calculate distance to centroid for
## observation in the group
More information about the Vegan-commits
mailing list