Learn R Programming

transltr (version 0.1.0)

uuid: Universally Unique Identifiers

Description

Generate a random UUID (Universally Unique Identifier) that complies to what RFC4122 prescribes. Such a value is also known as a version 4 UUID.

Usage

uuid()

uuid_raw()

uuid_is(x)

Value

uuid() returns a character of length 1 containing exactly 36 characters: 32 hexadecimal characters and 4 hyphens (used as separators).

uuid_raw() returns a raw vector of length 16.

uuid_is() returns a logical vector having the same length as x. It checks whether its elements are valid version 4 (variant 1) UUIDs or not. It returns FALSE for any other kind of UUID.

Arguments

x

An R object.

Details

uuid() calls uuid_raw() and formats its output accordingly.

Pseudo-random bytes are generated with sample() whenever uuid_raw() is called. This is most likely done before runtime when Translator objects are created. uuid_raw() samples values in the [0, 255] range with replacement and converts them to raw values. The user must ensure that the underlying seed is appropriate when generating UUIDs. See set.seed() for more information.

See Also

Examples

Run this code
uuid()
uuid_raw()
uuid_is(uuid())      ## TRUE
uuid_is(uuid_raw())  ## FALSE, uuid_raw() does not return a string.

Run the code above in your browser using DataLab