ourMELONS/R/findEmptyPop.R
2022-02-03 10:43:34 +01:00

12 lines
397 B
R
Raw Permalink 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(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))
}