[Analogue-commits] r372 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Oct 7 02:09:15 CEST 2013
Author: gsimpson
Date: 2013-10-07 02:09:14 +0200 (Mon, 07 Oct 2013)
New Revision: 372
Modified:
pkg/R/distance.R
Log:
fixes a bug in oldDistance() with Kendalls coef in the only-x case
Modified: pkg/R/distance.R
===================================================================
--- pkg/R/distance.R 2013-10-06 22:48:37 UTC (rev 371)
+++ pkg/R/distance.R 2013-10-07 00:09:14 UTC (rev 372)
@@ -83,7 +83,14 @@
}
kendall <- function(x, y, maxi)
{
- sum(maxi - pmin(x, y))
+ ## the sum in the else isn't right if x == y
+ ## then the dissimilarity should be 0
+ out <- if (isTRUE(all.equal(sum(x-y), 0))) {
+ 0
+ } else {
+ sum(maxi - pmin(x, y))
+ }
+ out
}
gower <- function(x, y, maxi, mini)
{
@@ -215,7 +222,8 @@
} else {
apply(y, 2, max, na.rm = NA.RM)
}
- maxi <- apply(rbind(maxX, maxY), 2, max, na.rm = NA.RM)
+ ##maxi <- apply(rbind(maxX, maxY), 2, max, na.rm = NA.RM)
+ maxi <- pmax(maxX, maxY)
if(method %in% c("gower", "alt.gower", "mixed")) {
## need the mins of each variable
## need to account for a single site (matrix with 1 row)
More information about the Analogue-commits
mailing list