Skip to contents

Re-implemented range.default default S3 method for numerical objects only. It returns c(NA, NA) instead of c(-Inf, Inf) for zero-length data without any warnings.

Usage

range_noinf(x, na.rm = FALSE, finite = FALSE)

Arguments

x

numeric S3 class, a sequence of numbers for which the range is computed.

na.rm

(logical)
indicating if NA should be omitted.

finite

(logical)
indicating if non-finite elements should be removed.

Value

2-elements vector of class numeric.

Examples

# Internal function - range_noinf
if (FALSE) {
range_noinf(1:5)
range_noinf(c(1:5, NA, NA), na.rm = TRUE)
range_noinf(numeric(), na.rm = TRUE)
range_noinf(c(1:5, NA, NA, Inf), na.rm = TRUE, finite = TRUE)
range_noinf(Inf)
range_noinf(Inf, na.rm = TRUE, finite = TRUE)
range_noinf(c(Inf, NA), na.rm = FALSE, finite = TRUE)
range_noinf(c(1, Inf, NA), na.rm = FALSE, finite = TRUE)
}