Set NA
for the values of x
that contain a single repeating character and
no other characters.
na_rep(x, n = 0)
A vector to check.
The minimum number times a character must repeat. If 0, the default,
then any string of one character will be replaced with NA
. If greater
than 0, the string must contain greater than n
number of repetitions.
The vector x
with NA
replacing repeating character values.
Uses the regular expression "^(.)\\1+$"
.
na_rep(c("VT", "NH", "ZZ", "ME"))
#> [1] "VT" "NH" NA "ME"