Because of how useful and prevalent the purrr-style lambda functions are, I've gotten used to them working across the tidyverse. Just ran into this usage where they aren't supported. I see stringr doesn't import rlang for as_mapper(), so this might not be possible.
library(stringr)
x <- c("[0,3)", "[12,100)", "[9,12)", "[3,6)", "[6,9)")
str_replace_all(x, "\\d+", function(p) as.numeric(p)/100)
#> [1] "[0,0.03)" "[0.12,1)" "[0.09,0.12)" "[0.03,0.06)" "[0.06,0.09)"
str_replace_all(x, "\\d+", ~as.numeric(.)/100)
#> Error: `replacement` must be a character vector
Created on 2020-02-10 by the reprex package (v0.3.0)
Because of how useful and prevalent the purrr-style lambda functions are, I've gotten used to them working across the tidyverse. Just ran into this usage where they aren't supported. I see stringr doesn't import rlang for
as_mapper(), so this might not be possible.Created on 2020-02-10 by the reprex package (v0.3.0)