Skip to contents

Launches a Shiny app wrapping clt.examp: it simulates several datasets from each of 4 different population shapes for a given sample size, and plots histograms of the samples (and of their means) with a normal reference curve.

Usage

ShinyCLTExamp(n = 1, reps = 10000, nclass = 16,
              norm.param = list(mean = 0, sd = 1),
              gamma.param = list(shape = 1, rate = 1/3),
              unif.param = list(min = 0, max = 1),
              beta.param = list(shape1 = 0.35, shape2 = 0.25))

Arguments

n

Initial sample size.

reps

Number of samples to take from each distribution. Passed through to clt.examp.

nclass

Number of bars in the histograms. Passed through to clt.examp.

norm.param

List with parameters passed to rnorm. Passed through to clt.examp.

gamma.param

List with parameters passed to rgamma. Passed through to clt.examp.

unif.param

List with parameters passed to runif. Passed through to clt.examp.

beta.param

List with parameters passed to rbeta. Passed through to clt.examp.

Details

This function requires the shiny package to be installed. With the default sample size of 1 the plots show the shapes of the 4 populations; increasing the sample size shows the sampling distribution of the mean becoming more normal, illustrating the Central Limit Theorem. It is best to select and retype the sample size value rather than use small increments.

Only n is interactive (via the “Sample Size” input in the app); reps, nclass, norm.param, gamma.param, unif.param, and beta.param are set once when ShinyCLTExamp is called and passed through to every call of clt.examp made by the app.

Value

Launches the app in non-blocking mode (via startApp) and returns a ShinyAppHandle immediately, so the R console remains available while the app runs in the background. Use handle$stop() to stop the app.

Author

Greg Snow 538280@gmail.com

Examples

if(interactive()) {
  h <- ShinyCLTExamp()
  # h$stop() # run this when finished with the app
  h <- ShinyCLTExamp(reps = 2000, gamma.param = list(shape = 2, rate = 1))
  # h$stop() # run this when finished with the app
}