tests: ordering Tests

Description Usage Arguments Details Value Note See Also Examples

Description

Tests vectors for (strictly) increasing, decreasing, monotonic and constant properties

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

Arguments

x

vector

na.rm

function or NULL; action to perform on input to handle the missing values

step

integer; step size for is_incremental. (Default: 1)'

...

used for passing default arguments

Details

Tests to various monotone properties of vectors.

is_incremental determines if x is incremental, i.e. monotonic and equally spaced.

is_uniform is a wrapper around is_incremental with step=1

is_[strictly_]monotonic determine the sort properties of x.

This differes from base::is.unsorted() which should more properly be called is.increasing since base::is.unsorted(3:1) == TRUE; 3:1 is obviously sorted.

is_sorted() is a alias for is_monotonic() and is_strictly_sorted() is an alias for is_strictly_monotonic().

Value

logical or NA. (NB: NA is returned because it is a logical vector and this is needed to put these results cleanly in tables.)

logical

Note

The behavior of this package is The functions base::is.unsorted() is perhaps misnamed and should properly be names is_not_increasing since base::is.unsorted(3:1) == TRUE after all vector 3,2,1 is sorted but not increasing.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  
  is_constant( rep(3,5) )

  is_increasing( 1:5 )                   # TRUE
  is_increasing( c(1,2,1,3) )            # FALSE
  
  is_increasing( c(1,NA,2,3) )           # NA 
  is_increasing( c(1,NA,2,3), na.omit )  # TRUE

  is_monotonic( 1:5 )                    # TRUE
  is_monotonic( -5:5 )                   # TRUE
  is_monotonic( 5:-5 )                   # TRUE
  is_monotonic( c(1,5,3))                # FALSE
  

  is_incremental(1:5 )
  is_incremental( c(1,2,5))
  
  is_incremental(1:5, step=NULL)
  is_uniform(1:5)


  is_monotonic( 1:3 )
  is_strictly_monotonic(1:3)
  
  is_monotonic( c(1,3,2) )
  is_strictly_monotonic( c(1,3,2) )
  
  is_sorted(1:3)
  is_sorted(c(1,3,2))   
  
  lets <- letters[1:3]
  is_monotonic( lets )
  is_monotonic( c('a', 'c', 'b') )
  
  is_sorted(1:10)
  
  is_sorted(-5:5)
  is_sorted(5:-5)
  
  is_sorted( letters )
  is_sorted( rev(letters) )
  

decisionpatterns/ordering documentation built on May 5, 2019, 7:09 a.m.