Learn R Programming

privacyR (version 1.0.1)

anonymize_id: Anonymize Patient Identifiers

Description

Replaces patient identifiers with anonymized versions while maintaining referential integrity (same IDs get the same anonymized value).

Usage

anonymize_id(x, prefix = "ID", seed = NULL, use_uuid = TRUE)

Value

A character vector of anonymized identifiers

Arguments

x

A vector of identifiers to anonymize (character, numeric, or factor)

prefix

A character string to prefix anonymized IDs (default: "ID")

seed

An optional seed for reproducible anonymization

use_uuid

Logical, if TRUE uses short UUIDs instead of sequential IDs (default: TRUE).

Examples

Run this code
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