library(tidyverse)
# toy data
df <- tibble(
text = c("abcdefgh", "abcd-efg", "123d*-e", "567xyz", "'!abc")
)
df
#> # A tibble: 5 × 1
#> text
#> <chr>
#> 1 abcdefgh
#> 2 abcd-efg
#> 3 123d*-e
#> 4 567xyz
#> 5 '!abc
How can I mutate a new column, say, issue
, which will identify if the columns text
contains non-alphanumeric characters excluding the -
.? In other words, the issue
column will be NA
if it only contains alphanumeric characters or -
.
df_wanted
#> # A tibble: 5 × 2
#> text issue
#> <chr> <chr>
#> 1 abcdefgh <NA>
#> 2 abcd-efg <NA>
#> 3 123d*-e *
#> 4 567xyz <NA>
#> 5 '!abc '!