ourMELONS/R/findEmptyPop.R

13 lines
368 B
R
Raw Normal View History

2020-11-09 08:33:02 +01:00
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 <- min(find(popDiff > 1))
}
return(list(emptyPop = emptyPop, pops = pops))
}