medR: Calculate the median and range

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function will calculate the median and range of a distribution, possibly for each level of a grouping variable.

Usage

1
2
3
4
5
6
7
## Default S3 method:
medR(x, na.rm = TRUE, ...)
## S3 method for class 'formula'
medR(formula, data = NULL, ..., subset,
   na.action = NULL,
   overall = FALSE,
   overall.label = "Overall")

Arguments

x

The numeric vector to summarize.

formula

A formula with the numeric vector on the left hand side and one or more grouping variables/factors on the right hand side.

data

A data.frame from which the variables in formula should be taken.

subset

An optional vector specifying a subset of observations to be used for the calculations.

overall

If TRUE, then an overall summary is included. The default is FALSE.

overall.label

If overall = TRUE, then this string is the identifier for the overall summary. The default is "Overall" but in the unlikely event that "Overall" is already a level in the data set then overall.label can be changed to something like "All".

na.rm

A logical value indicating whether NA values should be stripped before the computation proceeds.

na.action

A function which indicates what should happen when the data contain NAs. The default is to ignore missing values in either the response or the grouping variable(s).

...

Arguments passed to quantile.

Details

With small sample sizes, some analysts find that the interquartile range is not very helpful and prefer to report the median and the range.

For the formula method, multiple variables on the right hand side of the formula are combined to form the unique levels by which the numeric vector is summarized. The underlying code is borrowed from boxplot so whatever works there will work here.

An intercept-only model does not work currently but that would be useful.

The ... argument can be used to specify which of nine quantile algorithms is used.

Value

The default method returns a numeric vector of length 3 showing the median, minimum, and maximum.

The formula method returns a numeric matrix with rows reprsenting the median, minimum, and maximum and columns representing the factor levels.

For both methods, the result is of class "medR" but it will probably change to to class "sumry" or something similar so that functions like meanSD return an object of the same class.

Author(s)

Stephen Weigand Weigand.Stephen@mayo.edu

See Also

medIQR, meanSD, summary, quantile, IQR, fivenum

Examples

1
2
3
data(sleep)
medR(sleep$extra)
medR(extra ~ group, data = sleep)

summarize documentation built on May 2, 2019, 6:51 p.m.