library(tidyverse)
library(stringr)
df <- tibble::tribble(
~tch_id, ~online_platform,
105, "Google",
106, "meet",
107, "Zoom",
108, "zoom",
109, "Google Meet",
112, "Microsoft Teams",
113, NA
)
# work
df %>%
filter(
str_detect(online_platform, regex("google|meet", ignore_case = TRUE))
)
#> # A tibble: 3 x 2
#> tch_id online_platform
#> <dbl> <chr>
#> 1 105 Google
#> 2 106 meet
#> 3 109 Google Meet
# does not work as expected, why?
df %>%
filter(
str_detect(online_platform, "(?!)google|meet")
)
#> # A tibble: 1 x 2
#> tch_id online_platform
#> <dbl> <chr>
#> 1 106 meet
Created on 2022-03-25 by the reprex package (v2.0.1)