ranges: Sample range

rangesR Documentation

Sample range

Description

This function computes the sample range.

Usage

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

Arguments

x

any numeric vector

na.rm

logical vector that determines whether the missing values should be removed or not. The default is FALSE.

finite

logical vector that determines whether non-finite values should be removed or not. The default is FALSE.

Details

"The range is the difference between the largest number and the smallest number in the set." Source: Onwubiko page 176.

The following statements are from range:

"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."

Value

ranges as the difference between the maximum and minimum values in x as a numeric vector. Unlike the range, ranges can't take character vectors as arguments, only numeric vectors.

Author(s)

Irucka Embry

Source

  1. r - How to not run an example using roxygen2? - Stack Overflow answered and edited by samkart on Jul 9 2017. (Also see the additional comments in response to the answer.) See https://stackoverflow.com/questions/12038160/how-to-not-run-an-example-using-roxygen2.

  2. devtools - Issues in R package after CRAN asked to replace dontrun by donttest - Stack Overflow answered by Hong Ooi on Sep 1 2020. (Also see the additional comments in response to the answer.) See https://stackoverflow.com/questions/63693563/issues-in-r-package-after-cran-asked-to-replace-dontrun-by-donttest.

References

Chinyere Onwubiko, An Introduction to Engineering, Mission, Kansas: Schroff Development Corporation, 1997, page 176.

See Also

sgm for geometric mean, shm for harmonic mean, cv for coefficient of variation (CV), rms for root-mean-square (RMS), relerror for relative error, and approxerror for approximate error.

Examples


# Example 1

install.load::load_package("iemisc", "rando")

set_n(100) # makes the example reproducible

x <- r_norm(.seed = 943)

ranges(x)


install.load::load_package("iemisc", "rando")

set_n(100) # makes the example reproducible

(r.x <- ranges(r_norm(.seed = 100))); r.x



# See Source 1 and Source 2

# Example 2 (from the base range function)

library(iemisc)

xi <- c(NA, 1:3, -1:1/0); xi

try(ranges(xi))

try(ranges(xi, na.rm = TRUE))

try(ranges(xi, finite = TRUE))




iemisc documentation built on Sept. 25, 2023, 5:09 p.m.