Fixed bugs on old functions
This commit is contained in:
parent
168f58899e
commit
f8f65f176c
5 changed files with 28 additions and 3 deletions
|
|
@ -5,15 +5,21 @@
|
|||
#' @param osuusTaulu Percentage table?
|
||||
#' @export
|
||||
computeIndLogml <- function (omaFreqs, osuusTaulu) {
|
||||
omaFreqs <- as.matrix(omaFreqs)
|
||||
osuusTaulu <- as.matrix(osuusTaulu)
|
||||
|
||||
apu <- repmat(t(osuusTaulu), c(1, dim(omaFreqs)[2]))
|
||||
apu <- c(apu) * omaFreqs # c() avoids deprecation error re. matrix ops
|
||||
apu <- times(apu, omaFreqs) # c() avoids deprecation error re. matrix ops
|
||||
if (length(apu) > 1) {
|
||||
apu <- colSums(as.matrix(apu))
|
||||
} else {
|
||||
apu <- sum(apu)
|
||||
}
|
||||
|
||||
if (any(apu < 0)) {
|
||||
# Workaround for log of a negative number
|
||||
apu <- as.complex(apu)
|
||||
}
|
||||
apu <- log(apu)
|
||||
|
||||
loggis <- sum(apu)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ computeRows <- function(rowsFromInd, inds, ninds) {
|
|||
}
|
||||
rows <- inds[, rep(1, rowsFromInd)]
|
||||
rows <- rows * rowsFromInd
|
||||
miinus <- repmat((rowsFromInd - 1):0, c(1, ninds))
|
||||
miinus <- repmat(t((rowsFromInd - 1):0), c(ninds, 1))
|
||||
rows <- rows - miinus
|
||||
rows <- matrix(t(rows), c(1, rowsFromInd * ninds))
|
||||
return(t(rows))
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ times <- function(a, b) {
|
|||
|
||||
if (is.null(dominant_mx)) {
|
||||
out <- a * b
|
||||
} else if (dominant_mx == "neither") {
|
||||
} else if (dominant_mx[1] == "neither") {
|
||||
a <- repmat(
|
||||
mx = a,
|
||||
n = c(dominant_dim[1] - nrow(a) + 1, dominant_dim[2] - ncol(a) + 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue