squash! Replaced 1:npops with seq_len(npops) (#25)
Replaced 1: with seq_len() and seq_along() (#25). Helps working around NULL and 0 values.
This commit is contained in:
parent
7bb1a8181e
commit
3d3131b68c
1 changed files with 6 additions and 6 deletions
12
R/indMix.R
12
R/indMix.R
|
|
@ -75,7 +75,7 @@ indMix <- function(c, npops, counts = NULL, sumcounts = NULL, max_iter = 100L, d
|
||||||
partitionSummary[, 1] <- zeros(30, 1)
|
partitionSummary[, 1] <- zeros(30, 1)
|
||||||
worstLogml <- -1e50
|
worstLogml <- -1e50
|
||||||
worstIndex <- 1
|
worstIndex <- 1
|
||||||
for (run in 1:nruns) {
|
for (run in seq_along(nruns)) {
|
||||||
npops <- npopsTaulu[[run]]
|
npops <- npopsTaulu[[run]]
|
||||||
if (dispText) {
|
if (dispText) {
|
||||||
dispLine()
|
dispLine()
|
||||||
|
|
@ -98,7 +98,7 @@ indMix <- function(c, npops, counts = NULL, sumcounts = NULL, max_iter = 100L, d
|
||||||
logml <- sumcounts_counts_logml$logml
|
logml <- sumcounts_counts_logml$logml
|
||||||
|
|
||||||
PARTITION <- zeros(ninds, 1)
|
PARTITION <- zeros(ninds, 1)
|
||||||
for (i in 1:ninds) {
|
for (i in seq_len(ninds)) {
|
||||||
apu <- rows[i]
|
apu <- rows[i]
|
||||||
PARTITION[i] <- initialPartition[apu[1]]
|
PARTITION[i] <- initialPartition[apu[1]]
|
||||||
}
|
}
|
||||||
|
|
@ -139,13 +139,13 @@ indMix <- function(c, npops, counts = NULL, sumcounts = NULL, max_iter = 100L, d
|
||||||
message(paste("Performing steps:", as.character(roundTypes)))
|
message(paste("Performing steps:", as.character(roundTypes)))
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n in 1:length(roundTypes)) {
|
for (n in seq_len(roundTypes)) {
|
||||||
round <- roundTypes[n]
|
round <- roundTypes[n]
|
||||||
kivaluku <- 0
|
kivaluku <- 0
|
||||||
|
|
||||||
if (kokeiltu[round] == 1) { # Askelta kokeiltu viime muutoksen j<>lkeen
|
if (kokeiltu[round] == 1) { # Askelta kokeiltu viime muutoksen j<>lkeen
|
||||||
} else if (round == 0 | round == 1) { # Yksil<69>n siirt<72>minen toiseen populaatioon.
|
} else if (round == 0 | round == 1) { # Yksil<69>n siirt<72>minen toiseen populaatioon.
|
||||||
inds <- 1:ninds
|
inds <- seq_len(ninds)
|
||||||
aputaulu <- cbind(inds, rand(ninds, 1))
|
aputaulu <- cbind(inds, rand(ninds, 1))
|
||||||
aputaulu <- sortrows(aputaulu, 2)
|
aputaulu <- sortrows(aputaulu, 2)
|
||||||
inds <- t(aputaulu[, 1])
|
inds <- t(aputaulu[, 1])
|
||||||
|
|
@ -276,7 +276,7 @@ indMix <- function(c, npops, counts = NULL, sumcounts = NULL, max_iter = 100L, d
|
||||||
muutoksia <- 1
|
muutoksia <- 1
|
||||||
kokeiltu <- zeros(nRoundTypes, 1)
|
kokeiltu <- zeros(nRoundTypes, 1)
|
||||||
rivit <- list()
|
rivit <- list()
|
||||||
for (i in 1:length(muuttuvat)) {
|
for (i in seq_len(muuttuvat)) {
|
||||||
ind <- muuttuvat[i]
|
ind <- muuttuvat[i]
|
||||||
lisa <- rows[ind, 1]:rows[ind, 2]
|
lisa <- rows[ind, 1]:rows[ind, 2]
|
||||||
rivit <- rbind(rivit, t(lisa))
|
rivit <- rbind(rivit, t(lisa))
|
||||||
|
|
@ -432,7 +432,7 @@ indMix <- function(c, npops, counts = NULL, sumcounts = NULL, max_iter = 100L, d
|
||||||
totalMuutos <- muutokset(1, emptyPop)
|
totalMuutos <- muutokset(1, emptyPop)
|
||||||
|
|
||||||
rivit <- list()
|
rivit <- list()
|
||||||
for (i in 1:length(muuttuvat)) {
|
for (i in seq_len(muuttuvat)) {
|
||||||
ind <- muuttuvat[i]
|
ind <- muuttuvat[i]
|
||||||
lisa <- rows[ind, 1]:rows[ind, 2]
|
lisa <- rows[ind, 1]:rows[ind, 2]
|
||||||
rivit <- c(rivit, lisa)
|
rivit <- c(rivit, lisa)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue