Skip to content

Commit

Permalink
Create binDst which can be called as function (also from jTransform)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjentsch committed Nov 10, 2024
1 parent 7d9cc02 commit 7398c1f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R/distances_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ distances_omv <- function(dtaInp = NULL, fleOut = "", varDst = c(), clmDst = TRU
} else if (grepl("^chisq$|^ph2$", nmeDst)) {
dstMtx <- clcFrq(dtaMtx, nmeDst)
# (3) binary data -----------------------------------------------------------------------------
} else if (grepl(paste0("^beuclid|^blwmn|^bseuclid|^bshape|^d$|^d_|^dice|^disper|^hamann|^jaccard|^k[1-2]$|^k[1-2]_|",
"^lambda|^ochiai|^pattern|^phi|^q$|^q_|^rr|^rt|^size|^ss[1-5]|^sm|^y$|^y_|^variance"), nmeDst)) {
} else if (binDst(nmeDst)) {
dstMtx <- clcBin(dtaMtx, nmeDst)
# (4) none ------------------------------------------------------------------------------------
} else if (grepl("^none$", nmeDst)) {
Expand All @@ -251,6 +250,12 @@ distances_omv <- function(dtaInp = NULL, fleOut = "", varDst = c(), clmDst = TRU
}

# helper and calculation functions ================================================================
# binary measures: check whether name is valid
binDst <- function(nmeDst = "") {
grepl(paste0("^beuclid$|^blwmn$|^bseuclid$|^bshape$|^d$|^dice$|^disper$|^hamann$|^jaccard$|^jaccard[s,d]$|^k[1-2]$|^lambda$|",
"^ochiai$|^pattern$|^phi$|^q$|^rr$|^rt$|^size$|^sm$|^ss[1-5]$|^variance$|^y$"), gsub("_\\d+_\\d+$", "", nmeDst))
}

# binary measures: calculation, calls mtcBin for each cell (variable pair comparison / matches)
clcBin <- function(m = NULL, t = "jaccard") {
# transform data matrix into a logical matrix
Expand Down

0 comments on commit 7398c1f

Please sign in to comment.