R/small_helpers.R

Defines functions capitalize_firstLetter

Documented in capitalize_firstLetter

#' Internal function to capitalize the first letter of a character
#' 
#' Internal helper function to capitalize the first letter of a character value.
#' The use case is to create a plot label like 'Age' from a variable name like
#' 'age'.
#' 
#' @param char Character value whose first letter should be capitalized
#' 
#' @import checkmate
#' 
capitalize_firstLetter <- function(char) {
  
  checkmate::assert_character(char, len = 1)
  
  
  char_cap <- paste0(toupper(substr(char, 1, 1)), substr(char, 2, nchar(char)))
  
  return(char_cap)
}

Try the APCtools package in your browser

Any scripts or data that you put into this service are public.

APCtools documentation built on Jan. 14, 2023, 1:15 a.m.