Skip to contents

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)

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.

Value

A vector of UIDs.

Examples

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

### Look at them
fiveUIDs;
#> [1] "[[uid=8022lycx]]" "[[uid=8022lycy]]" "[[uid=8022lycz]]" "[[uid=8022lyd0]]"
#> [5] "[[uid=8022lyd1]]"

### 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
);
#> [1] "[[uid=7zqst63b]]" "[[uid=7zqst63c]]" "[[uid=7zqst63d]]" "[[uid=7zqst63f]]"
#> [5] "[[uid=7zqst63g]]"

### Produce five more UIDs to show
### their 'progression'
rock::generate_uids(5);
#> [1] "[[uid=8022lycz]]" "[[uid=8022lyd0]]" "[[uid=8022lyd1]]" "[[uid=8022lyd2]]"
#> [5] "[[uid=8022lyd3]]"

### Produce a set of five UIDs that follow
### the first set of five UIDs
rock::generate_uids(
  5,
  follow = fiveUIDs
);
#> [1] "[[uid=8022lyd2]]" "[[uid=8022lyd3]]" "[[uid=8022lyd4]]" "[[uid=8022lyd5]]"
#> [5] "[[uid=8022lyd6]]"

### Follow with a 'distance' of 5 utterances
rock::generate_uids(
  5,
  follow = fiveUIDs,
  followBy = 5
);
#> [1] "[[uid=8022lyd7]]" "[[uid=8022lyd8]]" "[[uid=8022lyd9]]" "[[uid=8022lydb]]"
#> [5] "[[uid=8022lydc]]"