Fixed bug involving scalar parsing
This commit is contained in:
parent
2e8ad9a89d
commit
9580a48a63
2 changed files with 16 additions and 3 deletions
|
|
@ -4,11 +4,22 @@
|
|||
#' @export
|
||||
|
||||
simuloiAlleeli <- function(allfreqs, pop, loc) {
|
||||
if (length(dim(allfreqs)) == 3) { # distinguish between arrays and matrices
|
||||
freqs <- allfreqs[, loc, pop]
|
||||
if (length(dim(allfreqs)) == 0) {
|
||||
freqs <- 1
|
||||
} else {
|
||||
freqs <- allfreqs[, loc]
|
||||
if (length(dim(allfreqs)) == 3) { # distinguish between array and matrix
|
||||
freqs <- allfreqs[, loc, pop]
|
||||
} else {
|
||||
freqs <- allfreqs[, loc]
|
||||
}
|
||||
}
|
||||
# freqs <- ifelse(is.null(length(dim(allfreqs)), allfreqs[loc], 0)
|
||||
# freqs <- switch() + 1,
|
||||
# allfreqs[, loc],
|
||||
# allfreqs[, loc, pop]
|
||||
# )
|
||||
|
||||
|
||||
cumsumma <- cumsum(freqs)
|
||||
arvo <- runif(1)
|
||||
isommat <- which(cumsumma > arvo)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue