Skip to contents

Randomly generated unique IDs are used throughout the package, created by rand_names(). If random strings are required that may not clash with a set of existing values, this can be guaranteed by passing them as old_names. A blockr_option() rand_id can be set to swap out the function responsible for ID generation.

Usage

rand_names(
  old_names = character(0L),
  n = 1L,
  max_tries = 100L,
  id_fun = blockr_option("rand_id", NULL)
)

adjective_animal(n)

sample_letters(n)

Arguments

old_names

Disallowed IDs

n

Number of IDs to generate

max_tries

Max number of attempts to create IDs that do not intersect with old_names

id_fun

A function with a single argument n that generates random IDs. A value of NULL defaults to ids::adjective_animal() if available and sample_letters otherwise.

Value

A character vector of length n where each entry contains length characters (all among chars and start/end with prefix/suffix), is guaranteed to be unique and not present among values passed as old_names.

Examples

rand_names()
#> [1] "even_finwhale"
rand_names(n = 5L)
#> [1] "operatic_moth"    "electric_cowbird" "forlorn_crab"     "obese_angora"    
#> [5] "dozy_pig"        
rand_names(id_fun = sample_letters)
#> [1] "afbsnayo"