I have the following script:
randomdiv <- function(ncells, ndivs, size, accuracy) { sz <- matrix(nrow = ncells, ncol = ndivs)
for (j in 1:ncells) {
total_subunits <- size
for (i in 1:ndivs)
{
accurate_subunits <- (size * accuracy)
random_subunits <- round(size - accurate_subunits)
random_inh <- rbinom(1, random_subunits, 0.5)
accurate_inh <- (accurate_subunits / 2)
total_inh <- 2 * (random_inh + accurate_inh)
sz[j,i] <- total_inh
total_subunits <- total_inh
}
}
return (do.call(rbind, replicate(100, sz, simplify = FALSE)))
}
Such that I thought randomdiv(5, 20, 10, 0)
would return a matrix with 500 rows, where the original sz
matrix had been replicated 100 times. In fact, this is the case. However, the replicates are identical rather than each replicate being a fresh generation of data, which is what I need.
Any ideas how I can make sure that each replicate is a new matrix, not literally a replicate of the first one to be generated?