Learn R Programming

xts (version 0.13.2)

isOrdered: Check If A Vector Is Ordered

Description

Performs check to determine if a vector is strictly increasing, strictly decreasing, not decreasing, or not increasing.

Usage

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

Value

Logical

Arguments

x

a numeric vector

increasing

test for increasing/decreasing values

strictly

are duplicates OK

Author

Jeffrey A. Ryan

Details

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

See Also

Examples

Run this code
# 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)

Run the code above in your browser using DataLab