Skip to contents

stm_random_char() generates a random string of characters of specified length, including numbers, lowercase, and uppercase letters based on user-defined options.

Usage

stm_random_char(
  n = 8,
  numbers = TRUE,
  include_lowercase = TRUE,
  include_uppercase = TRUE,
  set_seed = NULL
)

Arguments

n

The length of the random string to generate. Defaults to 8.

numbers

Whether to include numeric digits (0-9). Defaults to TRUE.

include_lowercase

Whether to include lowercase letters. Defaults to TRUE.

include_uppercase

Whether to include uppercase letters. Defaults to TRUE.

set_seed

Optional. An integer seed for random number generation. Defaults to NULL (no fixed seed).

Value

A random string of characters of length n.

Examples

# Generate a random string with default parameters
stm_random_char()
#> [1] "5ujP3K74"

# Generate a random string with only lowercase letters
stm_random_char(include_uppercase = FALSE)
#> [1] "7bm3i5w7"

# Generate a random string with only numbers
stm_random_char(include_lowercase = FALSE, include_uppercase = FALSE)
#> [1] "54458308"