R/camelCase.R

Defines functions camelCase

Documented in camelCase

#' converts strings to camelCase
#'
#' converts strings to camelCase
#' @param x a string
#' @keywords camelCase
#' @export
#' @examples
#' camelCase("begin with")

camelCase <- function(x) {
  dplyr::case_when(
    !is.character(x) ~ as.character(x),
    is.na(x) ~ NA_character_,
    !stringr::str_detect(x, "[:punct:]| ") ~ keda::first_to_lower(x),
    TRUE ~
      stringr::str_replace_all(x, "[:punct:]", " ") %>%
      stringr::str_to_title(.) %>%
      stringr::str_remove_all(., " ") %>%
      keda::first_to_lower()
  )
}
Kidapt/keda documentation built on Nov. 23, 2019, 3:35 a.m.