forcats (version 0.4.0)

fct_anon: Anonymise factor levels

Description

Replaces factor levels with arbitary numeric identifiers. Neither the values nor the order of the levels are preserved.

Usage

fct_anon(f, prefix = "")

Arguments

f

A factor.

prefix

A character prefix to insert in front of the random labels.

Examples

Run this code
# NOT RUN {
gss_cat$relig %>% fct_count()
gss_cat$relig %>% fct_anon() %>% fct_count()
gss_cat$relig %>% fct_anon() %>% fct_count()
gss_cat$relig %>% fct_anon("X") %>% fct_count()
# }

Run the code above in your browser using DataLab