Test, Check, Verify, Investigate the Monotonic Properties of Vectors

Functions to test/check/verify/investigate the ordering of vectors. The 'is_[strictly_]*' family of functions test vectors for 'sorted', 'monotonic', 'increasing', 'decreasing' order; 'is_constant' and 'is_incremental' test for the degree of ordering. `ordering` provides a numeric indication of ordering -2 (strictly decreasing) to 2 (strictly increasing).

Test/Check/Verify/Investigate the Ordering of Vectors

ordering provides several functions for testing/checking/verify/investigating the ordering of vectors (numeric or otherwise).

The packages has the following tests:


Where * can be one of:

  • monotonic -or- sorted whether the values are (strictly) ordered
  • increasing whether the values are in (strictly) increasing ordered
  • decreasing whehter the values are in (strictly) decreasing ordered

In addition:

  • is_constant whether all values are equal
  • is_incremental whether x is incremental, ordered and equally spaced
  • monotoniciy reports the degree of monotonicty.


Install using the standard methods

# -OR-
devtools::install_github( "decisionpatterns/ordering")


The usage of the packages is probably best demonstrated by a few examples:

x <- 1:5

is_sorted(x)              # TRUE
is_strictly_sorted(x)     # TRUE

is_increasing(x)          # TRUE    
is_strictly_increasing(x) # TRUE

is_decreasing(x)          # FALSE
is_strictly_decreasing(x) # FALSE

is_sorted(x)              # TRUE
is_strictly_sorted(x)     # TRUE 

is_constant(x)            # FALSE
is_incremental()          # TRUE

monotonicity(x)           # 2 - strictly increasing


ordering 0.7.0

monotone 0.4.1

  • Add is_strictly_sorted as alias for is_strictly_monotonic
  • Update DESCRIPTION and README.md
  • Fix docs
  • Add tests

monotone 0.4.0

  • Break apart code into smaller files
  • Fix spelling monotonoc
  • add is_monotonic and is_strictly_monotonic

monotone 0.3.0

  • Added a NEWS.md file to track changes to the package.
  • Fixed documentation

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.7.0 by Christopher Brown, 2 years ago


Report a bug at https://github.com/decisionpatterns/ordering/issues

Browse source code at https://github.com/cran/ordering

Authors: Christopher Brown [aut, cre] , Decision Patterns [cph]

Documentation:   PDF Manual  

GPL (>= 2) license

Suggests testthat, na.tools

See at CRAN