Skip to contents

Launches a Shiny app with a scatterplot of bivariate data and slider inputs to interactively change the population correlation, the number of observations, and the random seed.

Usage

ShinyCorExamp(n = 100, seed = 1, initial_cor = 0)

Arguments

n

Initial number of observations to plot.

seed

Initial random seed used to generate the data.

initial_cor

Initial value of the correlation slider.

Details

This function requires the shiny package to be installed. It starts a local Shiny app (via runApp) with a slider for the correlation (ranging from -1 to 1), a numeric input for the number of observations, and a numeric input for the random seed. Whenever an input changes, new bivariate normal data are generated with the specified correlation and plotted as a scatterplot, with the correlation value shown in the plot title.

This is useful for building intuition about how scatterplots look for different values of the correlation coefficient.

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

See also

Examples

if(interactive()) {
  h <- ShinyCorExamp()
  # h$stop() # run this when finished with the app
}