Learn R Programming

assertive (version 0.2-6)

assert_is_unsorted: Is the input unsorted?

Description

Checks to see if the input is unsorted (without the cost of sorting it).

Usage

assert_is_unsorted(x, na.rm = FALSE, strictly = FALSE)

is_unsorted(x, na.rm = FALSE, strictly = FALSE,
  .xname = get_name_in_parent(x))

Arguments

x
Input to check.
na.rm
If TRUE, remove NAs before checking.
strictly
If TRUE, equal values count as unsorted.
.xname
Not intended to be used directly.

Value

  • is_unsorted reimplements is.unsorted, providing more information on failure. assert_is_unsorted returns nothing but throws an error if is_unsorted returns FALSE.

See Also

is.unsorted.

Examples

Run this code
assert_is_unsorted(c(1, 3, 2))
assert_is_unsorted(c(1, 1, 2), strictly = TRUE)
#These tests should fail.
dont_stop(assert_is_unsorted(c(1, 1, 2)))
dont_stop(assert_is_unsorted(c(2, 1, 0)))

Run the code above in your browser using DataLab