ID EN
Math Functions

range

R Base 3.6.2

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

Syntax

R
range(&#8230;, na.rm = FALSE)<p></p><p># S3 method for default
range(&#8230;, na.rm = FALSE, finite = FALSE)</p>

Arguments

Parameter Description
&#8230; 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.

Details

range is a generic function: methods can be defined for it directly or via the Summary group generic. For this to work properly, the arguments … should be unnamed, and dispatch is on the first argument. If na.rm is FALSE, NA and 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.

Examples

Example
R
# NOT RUN {
(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)
# }

See Also

min max. The extendrange() utility in package grDevices.