R: Range of Values (original) (raw)

range {base} R Documentation

Description

range returns a vector containing the minimum and maximum of all the given arguments.

Usage

range(..., na.rm = FALSE)
## Default S3 method:
range(..., na.rm = FALSE, finite = FALSE)
## same for classes 'Date' and 'POSIXct'

.rangeNum(..., na.rm, finite, isNumeric)

Arguments

... any numeric or character objects.
na.rm logical, indicating if NA's should be omitted.
finite logical, indicating if all non-finite elements should be omitted.
isNumeric a function returning TRUE orFALSE when called on c(..., recursive = TRUE),is.numeric() for the default range() method.

Details

range is a generic function: methods can be defined for it directly or via the [Summary](../../base/help/S3groupGeneric.html) group generic. For this to work properly, the arguments ... should be unnamed, and dispatch is on the first argument.

If na.rm is FALSE, NAand NaN values in any of the arguments will cause NA values to be returned, otherwise NA values are ignored.

If finite is TRUE, the minimum and maximum of all finite values is computed, i.e.,finite = TRUE includes na.rm = TRUE.

A special situation occurs when there is no (after omission of NAs) nonempty argument left, see [min](../../base/help/min.html).

S4 methods

This is part of the S4 [Summary](../../methods/html/S4groupGeneric.html)group generic. Methods for it must use the signaturex, ..., na.rm.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language. Wadsworth & Brooks/Cole.

See Also

[min](../../base/help/min.html), [max](../../base/help/max.html).

The [extendrange](../../grDevices/html/extendrange.html)() utility in package grDevices.

Examples

(r.x <- range(stats::rnorm(100)))
diff(r.x) # the SAMPLE range

x <- c(NA, 1:3, -1:1/0); x
range(x)
range(x, na.rm = TRUE)
range(x, finite = TRUE)

[Package _base_ version 4.6.0 Index]