#' Generate random strings
#'
#' Generate a vector of random alphanumeric strings each of an arbitrary length.
#'
#' @param n Number of strings to generate (default 1).
#' Will attempt to coerce to integer value.
#'
#' @param len Length of strings to generate (default 8).
#' Will attempt to coerce to integer value.
#'
#' @return Character vector of random strings.
#'
#' @author Alex Chubaty
#' @export
#' @rdname rndstr
#'
#' @examples
#' set.seed(11)
#' rndstr()
#' rndstr(len = 10)
#' rndstr(n = 5, len = 10)
#' rndstr(n = 5)
rndstr <- function(n = 1, len = 8) {
unlist(lapply(character(n), function(x) {
x <- paste0(sample(c(0:9, letters, LETTERS), size = len, replace = TRUE), collapse = "")
}))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.