R/capwords.R

Defines functions capwords

Documented in capwords

#' Title
#'
#' @param s
#' @param strict
#'
#' @export
#'
capwords <- function(s, strict = FALSE) {
  cap <- function(s) paste(toupper(substring(s, 1, 1)),
                           {s <- substring(s, 2); if(strict) tolower(s) else s},
                           sep = "", collapse = " " )
  s <- tolower(s)
  sapply(strsplit(s, split = " "), cap, USE.NAMES = !is.null(names(s)))
}
ThinkR-open/prenomsapp documentation built on Feb. 21, 2023, 7:08 p.m.