You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When called with NA as a pattern, str_remove fails loudly about a type mismatch. When called with NA_character_ as a pattern, it silently returns NA. Is this the expected behavior? If so it doesn't seem to be documented anywhere. Personally, I was expecting that str_remove would have returned the input string unmodified in this scenario (as there is nothing specified to remove), or alternatively failed with an error message.
library(stringr)
str_remove("test", NA)
#> Error in `str_replace()`:#> ! `pattern` must be a string, not `NA`.
str_remove("test", NA_character_)
#> [1] NA# What lead to discovery of this, though str_c is behaving as expected returning NA_character_string_to_remove=NA# a blank cell in a data frame
str_remove_all("test", str_c("\\b",string_to_remove,"\\b"))
#> [1] NA
When called with
NA
as a pattern,str_remove
fails loudly about a type mismatch. When called withNA_character_
as a pattern, it silently returns NA. Is this the expected behavior? If so it doesn't seem to be documented anywhere. Personally, I was expecting thatstr_remove
would have returned the input string unmodified in this scenario (as there is nothing specified to remove), or alternatively failed with an error message.Created on 2024-04-11 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: