From e31dec27863f7aa501dbb0bdada3eeff9228285c Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Mon, 9 Nov 2020 08:33:02 +0100 Subject: [PATCH] Translated findEmptyPop --- R/findEmptyPop.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 R/findEmptyPop.R 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)) +}