ordering {ordering}R Documentation

ordering

Description

Determining the ordering (montonicity) of a vector

Usage

ordering(x, na.rm = TRUE)

monotonicity(x, na.rm = TRUE)

Arguments

x

numeric vector

na.rm

logical; whether to omit NA values. (Default: TRUE)

Details

monotonicty determines the monotonicy (first derivative) of a numeric vector as one of:

ordering tests, e.g. is_increasing are more efficient at testing.

monotonicity() is an alias for ordering.

Value

integer;

References

http://en.wikipedia.org/wiki/Monotonic_function http://stackoverflow.com/questions/13093912/how-to-check-if-a-sequence-of-numbers-is-monotonically-increasing-or-decreasing

Examples

  ordering( 1:3 )      # 2  
  ordering( c(1,1,3) ) # 1 
  ordering( c(1,0,1) ) # 0  "No ordering, does not apply constant"
  ordering( c(3,1,1) ) # -1
  ordering( 3:1 )      # -2
  

[Package ordering version 0.7.0 Index]