It is not clear what you want as a result. but I think you can put the code in a function and use the dot argument ...as a solution to provide additional parameters (e.g. distribution parameters).
central.simul <- function(N, ns,type = c("runif", "rnorm", "rbinom"),...){
type <- match.arg(type)
msample <- rep(NA,N)
for(i in 1:N){
sam <- switch(type,
runif = runif(ns)*10,
rnorm = rnorm(ns)*10,
rbinom = rbinom(ns,...))
msample[i] <- mean(sam)
add.hist <- i > 1
h <- hist(msample, breaks=seq(0,10, len=50),
xlim=c(0,10), col=grey(.9),
xlab="", main="Central Limit Theorem", border="blue", las=1,add=add.hist)
points(sam, rep(max(h$count), length(sam)),
pch=16, col=grey(.2))
points(msample[i], max(h$count),
col="red", pch=15)
text(10, max(h$count), paste0("sample no ", i))
hist(msample[i], breaks=seq(0,10, len=50),
xlim=c(0,10), col="red", add=T,
xlab="", border="white", las=1)
Sys.sleep(.1)
}
}
, :
central.simul(10,3,'runif')
central.simul(10,3,'rbinom',size=2,prob=0.5)
, rnorm, ( , ), .