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 can manipulate the number of individuals in the sample and the shape of the population to determine how these attributes affect the calculation of the mean and median.

Usage

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

Arguments

x

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

outlier

A string indicating 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.

Value

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

Examples

if (interactive()) {

## Examples with simulated data
##   no outlier
meanMedian()

##   outlier at minimum
meanMedian(outlier="min")

##   no outlier
meanMedian(outlier="max")

}

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

[Package NCStats version 0.3.4 Index]