meanMedian {NCStats}R Documentation

Dynamic simulations to demonstrate how the mean and median are computed.

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

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. If the user is not using RStudio or the manipulate package is not installed, then an attempt is made to produce the dynamic graph with Tcl/Tk using the functions in the relax package.

Value

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

Examples

## 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)


[Package NCStats version 0.4.7 Index]