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/jGBV documentation built on Oct. 9, 2022, 6:38 a.m.