To allow unique reference to constructs, they require unique identifiers. These functions generate such identifiers by combining one or more identifier prefixes (usually a human-readable construct name such as 'attitude') with a unique identifier based on the second the identifier was generated. The identifier prefix may only contain lowercase and uppercase letters and underscores.

generate_id(
  prefix = paste(sample(letters, 4), collapse = ""),
  stopOnIllegalChars = FALSE,
  origin = Sys.time()
)

generate_ids(x, stopOnIllegalChars = FALSE)

Arguments

prefix

An identifier prefix.

stopOnIllegalChars

Whether to base::stop() or produce a base::warning() when encountering illegal characters (i.e. anything other than a letter or underscore).

origin

The time and date to use to generate the identifier.

x

A vector of identifier prefixes.

Value

a character vector containing the identifier(s).

Examples

generate_id('attitude');
#> [1] "attitude_7s1f0qs0"