R/create_anon_chars.R

Defines functions create_anon_chars

Documented in create_anon_chars

#' Create unique character strings
#'
#' Create a new vector with unique character strings as entries
#'
#' @param l integer
#'
#' @return character
#' @export
#'
#' @examples
#' create_anon_chars(30)
create_anon_chars <- function(l) {
  if (l <= 26) {
    return (LETTERS[1:ceiling(l)])
  } else {
    x <- tidyr::expand_grid(LETTERS, create_anon_chars(ceiling(l/26))) %>%
      tidyr::unite(x, sep="") %>%
      dplyr::pull(x)
    return (x[1:l])
  }
}
juliangrimm225/anonymizeR documentation built on March 22, 2021, 1:51 p.m.