isOrdered: Check If A Vector Is Ordered

isOrderedR Documentation

Check If A Vector Is Ordered

Description

Check if a vector is strictly increasing, strictly decreasing, not decreasing, or not increasing.

Usage

isOrdered(x, increasing = TRUE, strictly = TRUE)

Arguments

x

A numeric vector.

increasing

Test for increasing (TRUE) or decreasing (FALSE) values?

strictly

When TRUE, vectors with duplicate values are not considered ordered.

Details

Designed for internal use with xts, this provides highly optimized tests for ordering.

Value

A logical scalar indicating whether or not x is ordered.

Author(s)

Jeffrey A. Ryan

See Also

is.unsorted()

Examples


# strictly increasing
isOrdered(1:10, increasing=TRUE)
isOrdered(1:10, increasing=FALSE)
isOrdered(c(1,1:10), increasing=TRUE)
isOrdered(c(1,1:10), increasing=TRUE, strictly=FALSE)

# decreasing
isOrdered(10:1, increasing=TRUE)
isOrdered(10:1, increasing=FALSE)


joshuaulrich/xts documentation built on Nov. 17, 2024, 6:37 a.m.