I am trying to generate a matrix sz by first applying a binomial, then adding values from the corresponding column of pombe_new_subs and this combined value being input as size for the following column.
After many frustrations, the following code is what I've ended up with and it just doesn't work - problems I'm coming across are;
# Error in sz[j, i + 1] = sz[, i] + pombe_new_subs[, i] : 
# number of items to replace is not a multiple of replacement length
pombe_new_subs <- rmultinom(3, 15, prob = c(0.3, 0.3, 0.3))
randomdiv <- function(nchrom, ndivs, size) {
    sz <- matrix(nrow = nchrom, ncol = ndivs) 
    for (j in 1:nchrom) {
        n <- size
        for (i in 1:ndivs) {
            n <- rbinom(1, n, 0.5)  
            sz[j,i] <- n
        }
        sz[j,i+1] = sz[ ,i] + pombe_new_subs[ ,i]
        sz[j, i+1] <- n
    }
    return (sz)
}
randomdiv(3, 3, 10)
I know this is probably a fairly simple looping exercise but frustration has entirely taken over.
