Skip to content

Conversation

@librill
Copy link
Contributor

@librill librill commented Dec 10, 2024

Added 4 functions for common programming use. Closes #573 .

All functions call an existing str_to_*() so locale argument respects the behavior of those functions

Aliases StrToPascal() and strToCamel() exist (str-to-kebab() is not a valid name)

@librill
Copy link
Contributor Author

librill commented Dec 10, 2024

CC: @kbodwin

@hadley
Copy link
Member

hadley commented Sep 5, 2025

Sorry for missing this. Are you still interested in finishing it off? No problems if not, as I'm happy to do it myself.

@kbodwin
Copy link

kbodwin commented Sep 5, 2025

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?

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
Copy link
Member

Choose a reason for hiding this comment

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

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") {
Copy link
Member

Choose a reason for hiding this comment

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

You could eliminate the separator argument by creating an internal function that both snake and kebab case uses.

@hadley hadley merged commit 32aaf82 into tidyverse:main Sep 22, 2025
11 checks passed
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

Successfully merging this pull request may close these issues.

Could a str_to_snake function be made to convert strings to snake-case?

3 participants