Skip to contents

Replace adjacent repeated elements in a vector

Usage

unfill(x, value = NA)

Arguments

x

A vector.

value

A replacement value of length 1.

Value

The vector x with adjacent repeated elements replaced with value.

See also

tidyr::fill() and vctrs::vec_fill_missing() for the reverse operation.

uniql() to identify non-repeated elements.

Examples

unfill(rep(1:3, 2:4))
#> [1]  1 NA  2 NA NA  3 NA NA NA
unfill(rep(c("A", "B"), 3:4), "")
#> [1] "A" ""  ""  "B" ""  ""  ""