diff --git a/R/findEmptyPop.R b/R/findEmptyPop.R new file mode 100644 index 0000000..e62b5e3 --- /dev/null +++ b/R/findEmptyPop.R @@ -0,0 +1,12 @@ +findEmptyPop <- function(npops) { + # % Palauttaa ensimm�isen tyhj�n populaation indeksin. Jos tyhji� + # % 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)) +}