title: Central Limit Theorem in R
body: <p>I wish to simulate the central limit theorem in order to demonstrate it, and I am not sure how to do it in R. I want to create 10,000 samples with a sample size of n (can be numeric or a parameter), from a distribution I will choose (uniform, exponential, etc...). Then I want to graph in one plot (using the par and mfrow commands) the original distribution (histogram), the distribution of the means of all samples, a Q-Q plot of the means, and in the 4th graph (there are four, 2X2), I am not sure what to plot. Can you please assist me in starting to program it in R ? I think once I have the simulated data I should be fine. Thank you.</p>
  
  <p>My initial attempt is below, it is too simple and I am not sure even correct.</p>
  
  <pre><code>r = 10000;
  n = 20;
  
  M = matrix(0,n,r);
  Xbar = rep(0,r);
  
  for (i in 1:r)
  {
    M[,i] = runif(n,0,1);
  }
  
  for (i in 1:r)
  {
    Xbar[i] = mean(M[,i]);
  }
  
  hist(Xbar);
  </code></pre>