Anonymize: To Make Anonymous a Data Frame

Description Usage Arguments Details Value Author(s) Examples

Description

Replaces factor and character variables by a combination of random sampled letters and numbers. Numeric columns are also transformed, see details.

Usage

1
2
3
4
Anonymize(.data, col.names = "V", row.names = "")

## Default S3 method:
Anonymize(.data, col.names = "V", row.names = "")

Arguments

.data

A vector or a data frame.

col.names

A string for column names.

row.names

A string for rown names, default is empty.

Details

Strings will is replaced by an algorithm with 52/102 chance of choosing a letter and 50/102 chance of choosing a number; then it joins everything in a 5-digits long character string.

Value

An object of the same type as .data.

Author(s)

Daniel Marcelino, dmarcelino@live.com.

Examples

1
2
3
4
5
6
7
8
dt <- data.frame(
Z = sample(LETTERS,10),
X = sample(1:10),
Y = sample(c("yes", "no"), 10, replace = TRUE)
)
dt;

Anonymize(dt)

SciencesPo documentation built on May 29, 2017, 9:28 p.m.