Generate UUIDs (Universally Unique IDentifiers). In previous versions this was simply a thin wrapper around uuid::UUIDgenerate, however this was subject to collisions on windows where relatively small numbers of UUIDs generated at the same time could return values that were identical. We now generate only version 4 UUIDs (i.e., random though with particular bits set).

uuid(n = 1, drop_hyphens = FALSE, use_time = NA)

Arguments

n

number of ids to return. If NULL, it instead returns the generating function

drop_hyphens

Drop the hyphens from the UUID?

use_time

Unused.

Author

Rich FitzJohn

Examples

# Generate one id
ids::uuid()
#> [1] "d6d0f941-9810-45f5-9329-856281d86068"

# Or a bunch
ids::uuid(10)
#>  [1] "1f70b060-4d86-49ad-9641-5d3ad79a61e7"
#>  [2] "b6f196b7-7a2d-4492-9ffc-60240d1f2b22"
#>  [3] "0cb2bc91-d761-4c2b-9385-c68c8f0faddd"
#>  [4] "2c83039e-04f5-429a-9dc7-b9ad47c36ff5"
#>  [5] "8c5ba89d-6688-4918-9f9a-09428bdd2689"
#>  [6] "83388440-3aa5-4d7f-8f9c-ea7b264ebed8"
#>  [7] "d1b3d1f4-bc73-4391-a569-ebc83d94158b"
#>  [8] "838ceb4e-69bb-49c0-9e62-19f87d58277f"
#>  [9] "a3793617-b85b-4a4a-a8aa-4298fecbae0b"
#> [10] "4fcb230e-d060-4c48-a56e-19efbc036640"

# More in the style of random_id()
ids::uuid(drop_hyphens = TRUE)
#> [1] "b87a4386f0b64d3f86dc05157867911c"