uuid: Function to generate randomly generated universally unique...

View source: R/uuid.R

uuidR Documentation

Function to generate randomly generated universally unique identifiers (UUIDs).

Description

A UUID is usually considered 32 lowercase hexadecimal digits displayed in five groups separated by hyphens (a total of 36 characters). The number of characters in the five groups are 8-4-4-4-12. There are about 3.4 x 10 ^ 38 possible UUID combinations, therefore it is unlikely that two UUIDs will be identical.

Usage

uuid(uppercase = FALSE, sep = "-")

uuid_rowwise(df)

Arguments

uppercase

Should the letters be returned as uppercase? Default is FALSE.

sep

What character should separate the five groups of characters? Default is hyphens (-).

df

Input data frame for row-wise transformation.

Details

base::sample is used as the random number generator. Random-base UUIDs are sometimes called version 4 UUIDs.

The uuid_rowwise function uses replicate so a variable/column in a data frame with unique uuids can be generated conveniently.

Author(s)

Christopher Bare, modified by Stuart K. Grange Originally from: http://gist.github.com/cbare/5979354

See Also

sample, replicate

Examples

## Not run: 

# Get a single identifier
identifier <- uuid()

# Print
identifier
"8e7675d5-4a87-4e0b-ae9b-9c97819aace5"

# Generate unique uuids for every row in a data frame
data_ozone$uuid <- uuid_rowwise(data_ozone)


## End(Not run)


skgrange/threadr documentation built on May 11, 2024, 12:16 p.m.