run.cor.examp: Interactively demonstrate correlations

View source: R/run.cor.examp.R

run.cor.exampR Documentation

Interactively demonstrate correlations

Description

Make a scatterplot and a Tk slider window that allows you to interactively set the correlation and/or R^2.

Usage

run.cor.examp(n=100, seed, vscale=1.5, hscale=1.5, wait=FALSE)
run.cor2.examp(n=100, seed, vscale=1.5, hscale=1.5, wait=FALSE)
run.old.cor.examp(n = 100, seed)
run.old.cor2.examp(n = 100, seed)

Arguments

n

Number of points to plot.

seed

What seed to use.

vscale

Vertical scale passed to tkrplot.

hscale

Horizontal scale passed to tkrplot.

wait

Should R wait for the tk window to close.

Details

The function run.cor.examp draws a scatterplot and allows you to set the correlation using a Tk slider window.

The function run.cor2.examp does the same, but has a slider for R^2 as well as the correlation, when either slider is moved the other one will update to match.

The 2 "old" versions use the default graphics device with a seperate window with the sliders, the versions without "old" in the name include the plot and sliders together in a single tk window.

The size of the plot can be changed by changing the values in the hscale and vscale boxes and clicking on the "Refresh" button.

Value

If wait is TRUE, then the return value is a list with the x and y values of the final plot.

If wait is FALSE (and in the "old" versions) an invisible NULL is returned.

Note

If wait is TRUE then R will wait until you click on the "Exit" button before you can use your R session again. If wait is FALSE then the tk window will appear, but R will regain control so that you can continue to use R as well as interact with the demonstration window.

Author(s)

Greg Snow 538280@gmail.com

See Also

cor, tkexamp

Examples

if(interactive()) {
  run.cor2.examp()
}

TeachingDemos documentation built on May 29, 2024, 5:59 a.m.