library(nimue)
library(individual)
# helper functions
divmod <- function(a,b){
a <- as.integer(a)
b <- as.integer(b)
c(
quo = a %/% b,
rem = a %% b
)
}
# n: number of "things"
# p: set of "places" they can go
distribute <- function(n,p){
n <- as.integer(n)
p <- as.integer(p)
distn <- rep(0L,p)
div <- divmod(n,p)
for(i in 0:(p-1)){
distn[i+1] <- div[["quo"]] + (i < div[["rem"]])
}
return(distn)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.