Interactively Demonstrate Correlation with a Shiny App
ShinyCorExamp.RdLaunches 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.
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
Examples
if(interactive()) {
h <- ShinyCorExamp()
# h$stop() # run this when finished with the app
}