## function for drawing the binomial distribution with parameters n and p. binomial.distribution <- function(n, p, ...){ plot(c(0:n), dbinom(c(0:n),n,p), type='h', xlab = "", ylab = "", main = paste("n=",n, " p=",p), yaxp = c(0, 0.5, 5), ... ) } ## dividing plot window into 4x3 plots. par(mfrow = c(4,3)) ## drawing binomial distributions for different parameter values. for (n in c(4,10,20,50)){ for (p in c(0.2,0.5,0.8)) { binomial.distribution(n, p, xlim = c(0,50), ylim = c(0,0.45) ) } } par(mfrow = c(1,1))