Suppose I have the following data frame in R:
df <- tribble(
~id, ~key,
1, "+999..3762962",
2, "0677219-30911",
3, "-739812//3918",
4, "+273$$8279838",
5, "1904-03940538",
6, NA
)
I want to filter every row that does not have a plus sign.
According to regex rules, with "[^...]" I should be able to exclude any character I want. However, when trying something like:
library(tidyverse)
df %>%
filter(str_detect(key, "[^\\+]"))
It doesn't work out, and it ends up filtering everything except missing values (it excludes the 6th row).
What am I doing wrong here? I have tried searching for similar questions, but they ask for very specific selections with regex, thus, the resulting code/suggestion is practically indecipherable to me. I believe the answer to this is very simple.
Thanks.