powered by
Replaces patient identifiers with anonymized versions while maintaining referential integrity (same IDs get the same anonymized value).
anonymize_id(x, prefix = "ID", seed = NULL, use_uuid = TRUE)
A character vector of anonymized identifiers
A vector of identifiers to anonymize (character, numeric, or factor)
A character string to prefix anonymized IDs (default: "ID")
An optional seed for reproducible anonymization
Logical, if TRUE uses short UUIDs instead of sequential IDs (default: TRUE).
ids <- c("P001", "P002", "P003", "P001") anonymize_id(ids) anonymize_id(ids, prefix = "PAT", seed = 123) anonymize_id(ids, use_uuid = FALSE, seed = 123) # Use sequential IDs
Run the code above in your browser using DataLab