-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
str_replace() isn't able to replace strings with NAs, since 1.1.0 #124
Comments
I don't think that should have ever worked — but it does need a better error message. |
Is there a reason for this behavior? Here's an example of some data I'm working on: d> glimpse(raw_data$survey)
Observations: 3,497
Variables: 21
$ site_surface <chr> "No Value", "No Value", "No Value", "No Value", "No Value", "No Value", "No Value", "No Val...
$ location_name <chr> "Bâtiment AP1", "Site Romans", "No Value", "No Value", "No Value", "No Value", "No Value", ...
$ location_surface <chr> "No Value", "No Value", "No Value", "No Value", "No Value", "No Value", "No Value", "No Val...
$ stats <chr> "Solved", "Solved", "Solved", "Solved", "Solved", "Solved", "Solved", "Solved", "Completed"...
$ value <chr> "No Value", "No Value", "No Value", "No Value", "No Value", "No Value", "No Value", "No", "...
... Something like For now, I'm using this workaround: tidy_gsub <- function(x, pattern, replacement, ...) {
gsub(pattern, replacement, x, ...)
}
raw_data$survey %>%
mutate_all(tidy_gsub, pattern = "No Value", replacement = NA) |
You'd be better off with |
I see your point. What do you think of an approach à la replace_no_value <- function(data, no_value = "") {
for (var in names(data)) {
data[[var]][data[[var]] == no_value] <- NA
}
data
} |
stringi seems to support it, so I implemented it anyway (you'll need to use |
Perfect! Thank you. |
In
stringr
version 1.0.0, the following worked fine:In
stringr
version 1.1.0, an error is thrown:Is this updated behavior intentional?
The text was updated successfully, but these errors were encountered: