inst/source/R/get_unique_string.R

#' Create a Fairly Unique String
#'
#' I sometimes need a fairly unique string, mostly for file names, that should
#' start with the current date.
#' @export
#' @return A fairly unique string.
#' @family file utilities
#' @examples
#' replicate(20, get_unique_string())
get_unique_string <- function() {
    name <- paste(sep = "_", strftime(Sys.time(), format = "%Y_%m_%d_%H_%M_%S"),
                  Sys.getpid(), sub("^file", "", basename(tempfile())))
    return(name)
}

Try the fritools package in your browser

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

fritools documentation built on Nov. 19, 2023, 1:06 a.m.