R/strings.R

Defines functions spaceAndTitle

Documented in spaceAndTitle

# Source file: strings.R
#
# MIT License
#
# Copyright (c) 2019 Victor Ordu

#' Modify Strings
#'
#' Creates spaces for underscores and changes text to title case
#'
#' @param str A character vector of strings that will be modified.
#'
#' @import stringr
#'
#' @return A character vector of the same length as \code{str}
#'
#' @export
spaceAndTitle <- function(str) {
  stopifnot(is.character(str))
  str %>%
    str_replace_all("_", " ") %>%
    str_to_title %>%
    str_trim
}
BroVic/raampGBV documentation built on Oct. 7, 2022, 11:06 p.m.