Add functions: str_to_pascal(), str_to_camel(), str_to_kebab(), str_to_snake()#577
Merged
hadley merged 16 commits intotidyverse:mainfrom Sep 22, 2025
Merged
Add functions: str_to_pascal(), str_to_camel(), str_to_kebab(), str_to_snake()#577hadley merged 16 commits intotidyverse:mainfrom
str_to_pascal(), str_to_camel(), str_to_kebab(), str_to_snake()#577hadley merged 16 commits intotidyverse:mainfrom
Conversation
Contributor
Author
|
CC: @kbodwin |
Member
|
Sorry for missing this. Are you still interested in finishing it off? No problems if not, as I'm happy to do it myself. |
|
We're happy to make changes if needed! But I'm not sure I see what's missing - do you see something more you'd want for this to be ready for review? |
hadley
reviewed
Sep 5, 2025
R/case.R
Outdated
| #' each word is capitalized. | ||
| #' * `str_to_sentence()` convert to sentence case, where only the first letter | ||
| #' of sentence is capitalized. | ||
| #' * `str_to_pascal()` converts to pascal case, where only the first letter of |
Member
There was a problem hiding this comment.
I'm not sure Pascal case is particularly well known (at least I didn't recognise it) so how about it make it an argument to str_camel_case(), e.g. first_upper = TRUE?
R/case.R
Outdated
| strToCamel <- str_to_camel | ||
| #' @export | ||
| #' @rdname case | ||
| str_to_snake <- function(string, separator = "_", locale = "en") { |
Member
There was a problem hiding this comment.
You could eliminate the separator argument by creating an internal function that both snake and kebab case uses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added 4 functions for common programming use. Closes #573 .
All functions call an existing
str_to_*()so locale argument respects the behavior of those functionsAliases
StrToPascal()andstrToCamel()exist (str-to-kebab()is not a valid name)