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
str_replace("abc", c(a="d", c = "e"))
#> Error in check_lengths(string, pattern, replacement) :
#> argument "replacement" is missing, with no default
I can understand why, since it should replace only one time, but I expected it would do the first possible replacement (either first in the pattern vector or first in position, I feel the common use case would be that only one would match, at least it was mine).
The doc mentions in the pattern arg description:
To perform multiple replacements in each element of string, pass supply a named vector (c(pattern1 = replacement1)).
But it doesn't mention that it applies only to str_replace_all()
I would expect the doc to be more precise and the output to be:
str_replace("abc", c(a="d", c = "e"))
#> [1] "dbc"
# or something like
str_replace("abc", c(a="d", c = "e"))
#> Error in str_replace(string, pattern, replacement) :
#> x `pattern` must be a string
#> i you provided a named vector, do you need `str_replace_all()` ?
The text was updated successfully, but these errors were encountered:
I can understand why, since it should replace only one time, but I expected it would do the first possible replacement (either first in the
pattern
vector or first in position, I feel the common use case would be that only one would match, at least it was mine).The doc mentions in the
pattern
arg description:But it doesn't mention that it applies only to
str_replace_all()
I would expect the doc to be more precise and the output to be:
The text was updated successfully, but these errors were encountered: