is_decreasing: Determine Whether a Vector is Increasing or Decreasing

View source: R/is_decreasing.R

is_decreasingR Documentation

Determine Whether a Vector is Increasing or Decreasing

Description

is_increasing() and is_decreasing() are trivial wrapper functions to enhance code readability. They determine whether a numerical vector is increasing or decreasing monotonically. strictly (default FALSE) excludes cases where the difference between consecutive elements is zero.

Usage

is_decreasing(vec, strictly = FALSE, na.rm = FALSE)

Arguments

vec

A numerical vector.

strictly

Does a difference of zero count as increasing/decreasing? By default, c(1, 1, 2) is increasing, with strictly = TRUE it is not.

na.rm

A logical value indicating whether NA values should be stripped before the vector is determined to be increasing or decreasing.

Value

logical.

Examples

is_increasing(c(1:10))
is_increasing(c(1, 2, 2, 2, 3), strictly = TRUE)
is_decreasing(c(3, 2, 2, 5, 3, 2, 1))

ldimartin0/ladtools documentation built on June 8, 2022, 3:30 p.m.