Learn R Programming

dwtools (version 0.8.3.9)

anonymize: Anonymize

Description

Mask data using hasing function

Usage

anonymize(x, algo)

Arguments

x
vector to anonymize
algo
character scalar to be used for digest function in digest package, read ?digest::digest.

Value

character vector of hashes, same length as length of x argument.

Examples

Run this code
suppressPackageStartupMessages(library(dwtools))

X = dw.populate(N=1e5, scenario="star")
DT <- joinbyv(X$SALES, list(X$CUSTOMER))
print(DT)
cols_to_mask <- c("cust_code", "cust_name", "cust_mail")
DT[, (cols_to_mask) := lapply(.SD, anonymize, "crc32"), .SDcols=c(cols_to_mask)]
print(DT)

Run the code above in your browser using DataLab