ourMELONS/R/poistaTyhjatPopulaatiot.R

16 lines
501 B
R
Raw Normal View History

2020-11-09 08:35:41 +01:00
poistaTyhjatPopulaatiot <- function(npops) {
# % Poistaa tyhjentyneet populaatiot COUNTS:ista ja
# % SUMCOUNTS:ista. P<>ivitt<74><74> npops:in ja PARTITION:in.
notEmpty <- matlab2r::find(apply(SUMCOUNTS, 1, function(x) any(x > 0)))
COUNTS <- COUNTS[, , notEmpty]
SUMCOUNTS <- SUMCOUNTS[notEmpty, ]
LOGDIFF <- LOGDIFF[, notEmpty]
2020-11-09 08:35:41 +01:00
for (n in 1:length(notEmpty)) {
2023-08-09 14:16:04 +02:00
apu <- matlab2r::find(PARTITION == notEmpty[n])
PARTITION[apu] <- n
}
npops <- length(notEmpty)
return(npops)
}