Learn R Programming

psyverse (version 0.2.6)

generate_id: 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)

Value

a character vector containing the identifier(s).

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.

Examples

Run this code
generate_id('attitude');

Run the code above in your browser using DataLab