Replaces factor levels with arbitrary numeric identifiers. Neither the values nor the order of the levels are preserved.
Examples
gss_cat$relig %>% fct_count()
#> # A tibble: 16 × 2
#> f n
#> <fct> <int>
#> 1 No answer 93
#> 2 Don't know 15
#> 3 Inter-nondenominational 109
#> 4 Native american 23
#> 5 Christian 689
#> 6 Orthodox-christian 95
#> 7 Moslem/islam 104
#> 8 Other eastern 32
#> 9 Hinduism 71
#> 10 Buddhism 147
#> 11 Other 224
#> 12 None 3523
#> 13 Jewish 388
#> 14 Catholic 5124
#> 15 Protestant 10846
#> 16 Not applicable 0
gss_cat$relig %>%
fct_anon() %>%
fct_count()
#> # A tibble: 16 × 2
#> f n
#> <fct> <int>
#> 1 01 15
#> 2 02 104
#> 3 03 23
#> 4 04 5124
#> 5 05 32
#> 6 06 147
#> 7 07 689
#> 8 08 71
#> 9 09 109
#> 10 10 388
#> 11 11 10846
#> 12 12 224
#> 13 13 95
#> 14 14 0
#> 15 15 93
#> 16 16 3523
gss_cat$relig %>%
fct_anon("X") %>%
fct_count()
#> # A tibble: 16 × 2
#> f n
#> <fct> <int>
#> 1 X01 95
#> 2 X02 147
#> 3 X03 388
#> 4 X04 23
#> 5 X05 224
#> 6 X06 93
#> 7 X07 5124
#> 8 X08 109
#> 9 X09 10846
#> 10 X10 104
#> 11 X11 0
#> 12 X12 71
#> 13 X13 3523
#> 14 X14 689
#> 15 X15 15
#> 16 X16 32