Learn R Programming

privacyR (version 1.0.1)

anonymize_locations: Anonymize Geographic Locations

Description

Anonymizes geographic locations by removing them or replacing with generic labels. Maintains referential integrity (same locations get the same value).

Usage

anonymize_locations(
  x,
  method = c("remove", "generalize"),
  prefix = "Location",
  seed = NULL,
  use_uuid = TRUE
)

Value

A character vector of anonymized locations

Arguments

x

A character vector of locations to anonymize

method

Character string specifying anonymization method: "remove" (default) removes location information, "generalize" replaces with generic location labels

prefix

For "generalize" method: prefix for generic locations (default: "Location")

seed

An optional seed for reproducible anonymization

use_uuid

Logical, if TRUE uses short UUIDs instead of sequential IDs (default: TRUE). Only applies when method = "generalize".

Examples

Run this code
locations <- c("New York, NY", "Los Angeles, CA", "Chicago, IL")
anonymize_locations(locations, method = "remove")
anonymize_locations(locations, method = "generalize", seed = 123)
anonymize_locations(locations, method = "generalize", 
                    use_uuid = FALSE, seed = 123)  # Use sequential IDs

Run the code above in your browser using DataLab