Learn R Programming

rock (version 0.9.6)

generate_uids: Generate utterance identifiers (UIDs)

Description

This function generates utterance identifiers. Utterance identifiers are Short Quasi-Unique Identifiers (SQUIDs) generated using the squids::squids() function.

Usage

generate_uids(x, origin = Sys.time(), follow = NULL, followBy = NULL)

Value

A vector of UIDs.

Arguments

x

The number of identifiers to generate.

origin

The origin to use when generating the actual identifiers; see the squids::squids() documentation.

follow

A vector of one or more UIDs (or a list; lists are recursively unlist()ed); the highest UID will be taken, converted to a timestamp, and used as origin (well, 0.01 second later), so that the new UIDs will follow that sequence.

followBy

When following a vector of UIDs, this can be used to specify the distance between the two vectors in centiseconds.

Examples

Run this code
### Produce and store five UIDs
fiveUIDs <-
  rock::generate_uids(5);

### Look at them
fiveUIDs;

### Use a specific origin to be able to reproduce
### a set of UIDs later (e.g. in a script)
uidOrigin <-
  as.POSIXct("2025-05-21 21:53:25 CEST");

rock::generate_uids(
  5,
  origin = uidOrigin
);

### Produce five more UIDs to show
### their 'progression'
rock::generate_uids(5);

### Produce a set of five UIDs that follow
### the first set of five UIDs
rock::generate_uids(
  5,
  follow = fiveUIDs
);

### Follow with a 'distance' of 5 utterances
rock::generate_uids(
  5,
  follow = fiveUIDs,
  followBy = 5
);

Run the code above in your browser using DataLab