is_same_as_last: Check for locally repeating values

View source: R/vectors.R

is_same_as_lastR Documentation

Check for locally repeating values

Description

Check for locally repeating values

Usage

is_same_as_last(xs)

replace_if_same_as_last(xs, replacement = "")

Arguments

xs

a vector

replacement

a value used to replace a repeated value. Defaults to "".

Value

is_same_as_last() returns TRUE when xs[n] the same as xs[n-1].

Examples

xs <- c("a", "a", "a", NA, "b", "b", "c", NA, NA)
is_same_as_last(xs)
replace_if_same_as_last(xs, "")

tjmahr/tjmisc documentation built on Feb. 8, 2023, 12:21 p.m.