diff --git a/R/str_sentence_case.R b/R/str_sentence_case.R index 6e5fed1..16d344a 100644 --- a/R/str_sentence_case.R +++ b/R/str_sentence_case.R @@ -8,5 +8,10 @@ #' #' @export -str_sentence_case <- function( string ) - stop( "Sentence case is not implemented yet.") \ No newline at end of file +str_sentence_case <- function( string ) { + # adapted from https://stackoverflow.com/questions/18509527/first-letter-to-upper-case + # behave as expected, even for short string (i.e. "" or "a") + substr(string, 1, 1) <- toupper(substr(string, 1, 1)) + substr(string, 2, nchar(string)) <- tolower(substr(string, 2, nchar(string))) + string +}