Skip to content
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

11.4.5 str_replace_all problem #278

Closed
DanOvando opened this issue Aug 17, 2016 · 1 comment
Closed

11.4.5 str_replace_all problem #278

DanOvando opened this issue Aug 17, 2016 · 1 comment

Comments

@DanOvando
Copy link

Hi Hadley,

Huge thanks for putting this book out there, amazing work as always. I've been going through the regex section (11.4.5) , and noticed what I believe is an error below

x <- c("1 house", "2 cars", "3 people")
str_replace_all(x, c("1" = "one", "2" = "two", "3" = "three"))
#> [1] "one house"  "one cars"   "one people"

Judging from the context, I think you want str_replace_all in this case to produce

#> [1] "one house"  "two cars"   "three people"

But it seems to be instead applying the first replacement to all matches? Suppose this is a stringr issue but thought it would be easier to point out here.

@hadley
Copy link
Owner

hadley commented Aug 17, 2016

Thanks! For future reference, filing in stringr is slightly easier for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants