I imagine this is incredibly simple but I cant seem to find the answer.
I am writing an IF statement but the test is if the object returns a character(0)
Many people forget that functions like str_locate_all() require %>% unlist() or %>% .[[1]].
Then you can easily detect character(0) with the length() function if > 0 one can safely use the output of str_locate_all() for example.
Example:
value <- str_extract_all("kvk :", ascii_digit(8,8)) %>% unlist()
if (length(value) > 0) {
# Do something
}