Skip to content

Commit

Permalink
Changed calculation for binary measures: Calculate the values in the …
Browse files Browse the repository at this point in the history
…main diagonal (so far, they were predefined)
  • Loading branch information
sjentsch committed Nov 10, 2024
1 parent 7398c1f commit 80140e7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions R/distances_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,14 @@ clcBin <- function(m = NULL, t = "jaccard") {
# extract transformation name
t <- strsplit(t, "_")[[1]][1]
n <- ncol(m)
# create a result matrix (first determine what goes into the main diagonal)
d <- ifelse(grepl("^d$|^disper$|^k1$|^rr$|^ss3$", t), NA,
ifelse(grepl("^beuclid$|^blwmn$|^bseuclid$|^bshape$|^jaccardd$|^pattern$|^size$|^variance$", t), 0, 1))
r <- matrix(d, n, n, dimnames = rep(dimnames(m)[2], 2))
# create a result matrix
r <- matrix(NA, n, n, dimnames = rep(dimnames(m)[2], 2))

for (i in seq(ifelse(grepl("^rr$|^d$|^disper$", t), 1, 2), n)) {
for (j in seq(1, i - ifelse(grepl("^rr$|^d$|^disper$", t), 0, 1))) {
for (i in seq(1, n)) {
for (j in seq(1, i)) {
# skip calculation of distance in the main diagonal for k1 and ss3
# (keep NA; if calculated, the limitation to 9999.999 [l. 366 / 392] would hit)
if (i == j && grepl("^k1$|^ss3$", t)) next
r[i, j] <- r[j, i] <- mtcBin(m[, i], m[, j], t)
}
}
Expand Down

0 comments on commit 80140e7

Please sign in to comment.