generate_id {psyverse}R Documentation

Generate unique identifier(s)

Description

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.

Usage

generate_id(
  prefix = paste(sample(letters, 4), collapse = ""),
  stopOnIllegalChars = FALSE
)

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).

x

A vector of identifier prefixes.

Value

a character vector containing the identifier(s).

Examples

generate_id('attitude');

[Package psyverse version 0.2.6 Index]