meanMedian: Dynamic simulations to demonstrate how the mean and median...

Description Usage Arguments Details Value Examples

View source: R/sims-teaching.R

Description

This function visually illustrates how the mean “balances” distances and the median “balances” individuals in a random sample from a known population. The user may plot their own data or compute a random sample from a beta distribution where the number of individuals in the sample and the shape of the population may be dynamically manipulated to determine how these attributes affect the calculation of the mean and median.

Usage

1
meanMedian(x = NULL, breaks = NULL, outlier = c("none", "max", "min"))

Arguments

x

An optional numeric vector (of actual data) to be used in the visual.

breaks

See description for hist.

outlier

A string that indicates whether the outlier should be modeled at the maximum (="max"), minimum (="min"), or not at all ="none"). This is ignored if x is not NULL or if this function is run in RStudio.

Details

If the user is using RStudio and the manipulate package is installed then the dynamic graph is produced in the “Plots” pane of RStudio. The plot controls may be accessed through the “gear” that is in the upper-left corner of the plot.

Value

None, but a graphic (if x is not null) or a dynamic graphic with sliders (if x is null) is produced (if using RStudio).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
## Examples with simulated data
meanMedian()
meanMedian(breaks=20)

## End(Not run)

## Example with user-derived data
meanMedian(c(1:7,25))
meanMedian(c(1:7,25),breaks=3)

droglenc/NCStats documentation built on June 5, 2021, 2:06 p.m.