monotonic: Determine Whether a Vector is Monotonic

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

Description

If each successive value in a numeric vector is less-than-or-equal-to the previous, or if each successive value is greater-than-or-equal-to the previous, we understand the vector as a whole to be monotonic. The functions nondecreasing and nonincreasing give element-wise diagnoses, showing positions at which the assertion holds (element 1 is always TRUE). Use strict=TRUE for strictly less-than or greater-than logic.

Usage

1
2
3
4
5
6
 ## Default S3 method:
nondecreasing(x, strict=FALSE, ...)
 ## Default S3 method:
nonincreasing(x, strict=FALSE, ...)
 ## Default S3 method:
monotonic(x, strict=FALSE, ...)

Arguments

x

vector

strict

if FALSE, repeated values are tolerated. See examples.

...

ignored

Value

logical. A single valueFor monotonic; A vector (same length as x) nondecreasing and nonincreasing.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

1
2
3
4
5
x <- c(1,2,2,3,4)
nondecreasing(x)
nonincreasing(x)
monotonic(x)
monotonic(x,strict=TRUE)

metrumrg documentation built on May 2, 2019, 5:55 p.m.