fct_anon: Anonymise factor levels

Description Usage Arguments Examples

View source: R/anon.R

Description

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

Usage

1
fct_anon(f, prefix = "")

Arguments

f

A factor.

prefix

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

Examples

1
2
3
gss_cat$relig %>% fct_count()
gss_cat$relig %>% fct_anon() %>% fct_count()
gss_cat$relig %>% fct_anon("X") %>% fct_count()

forcats documentation built on Jan. 28, 2021, 1:06 a.m.