Skip to content
Snippets Groups Projects
Verified Commit 888b3eb6 authored by Gärber, Florian's avatar Gärber, Florian
Browse files

fix: Set mean adjusted agreement with same variable to NA

#4 Fixed the issue of writing past the end of the vector, however neglected use-cases where `candidates` was not equal to `variables`.
This patch removes setting NA in `mean.index()` entirely, and applies the colname/rowname-wise fix to the created matrix instead.
This fixes the issue where in the README example, the MAA of X7 with X2 would be set to NA, instead of with X7.
This should also keep things stable against shuffled columns, or supplying variables in a different order than candidates, and should not encounter the issue of extra NAs.
parent 56136bd7
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ meanAdjAgree <- function(trees, variables, allvariables, candidates, t, s.a, sel
)
colnames(results.allvar) <- candidates
rownames(results.allvar) <- variables
results.allvar[outer(rownames(results.allvar), colnames(results.allvar), "==")] <- NA
if (select.var) {
# calculate threshold and select variables according to it
......@@ -67,7 +68,6 @@ mean.index <- function(i, list.res, index.variables) {
list <- list.res[which(names(list.res) == index.variables[i])]
mean.list <- round(Reduce("+", list) / length(list), 2)
if (length(mean.list) > 0) {
mean.list[i] <- NA
return(mean.list)
} else {
return(rep(NA, length(index.variables)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment