ourMELONS/R/findEmptyPop.R
2024-04-11 09:47:29 +02:00

12 lines
405 B
R
Raw Blame History

findEmptyPop <- function(npops) {
# % Palauttaa ensimm<6D>isen tyhj<68>n populaation indeksin. Jos tyhji<6A>
# % populaatioita ei ole, palauttaa -1:n.
pops <- t(unique(globals$PARTITION))
if (length(pops) == npops) {
emptyPop <- -1
} else {
popDiff <- diff(c(0, pops, npops + 1))
emptyPop <- base::min(matlab2r::find(popDiff > 1))
}
return(list(emptyPop = emptyPop, pops = pops))
}