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

Replace instances of stringr::str_sub() with base R equivalent #2195

Merged
merged 9 commits into from
Nov 19, 2022

Conversation

rich-iannone
Copy link
Collaborator

This replaces all instances of stringr::str_sub() with the base R equivalent str_substitute().

Copy link
Owner

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you borrowed str_substitute() from your own packages, but we don't really need a sophisticated function here. The extract function stringr::str_sub() can be directly replaced by base::substr(), and the replacement function str_sub<- is a little trickier, since substr<- is not vectorized and has other quirks. Replacing parts of a string doesn't seem to be a complicated task, so I wrote the str_replace() function in utils-string.R, which seems to work (has passed the tests).

Thanks!

@yihui yihui marked this pull request as ready for review November 19, 2022 06:04
@yihui yihui merged commit 5a2cb72 into master Nov 19, 2022
@yihui yihui deleted the str-sub-replace branch November 19, 2022 06:05
@rich-iannone
Copy link
Collaborator Author

Wow, thank you for taking this in another direction and right to the finish line! I was going to make the str_substitute<- function this weekend but now I don't have to. Alright! Onto the next one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants