recode_gender()gendercoder package.To see the full dictionary used for recodes, see GenderDictionary_List.csv
Review the data (d11)
# A tibble: 7 x 2
id gender
<dbl> <chr>
1 345 mal
2 346 male
3 347 nonbinary
4 348 trans
5 349 feamle
6 350 f
7 351 I'm a man
Recode open-response gender into standardized gender categories based on a built-in dictionary.
Note: In this package you can choose between a broader recoding of gender, using the argument dictionary = manylevels_en (the default) or a narrower recoding using the argument dictionary = fewlevels_en.
Note: You can also choose to retain any values that are not found using the argument retain_unmatched = TRUE.
Note: We are recoding into a new variable using
dplyr::mutate() and naming the new variable a different
name than the original. It keeps both the new and old versions of the
variable.
d11 %>%
dplyr::mutate(gender_new = gendercoder::recode_gender(gender, retain_unmatched = TRUE))
# A tibble: 7 x 3
id gender gender_new
<dbl> <chr> <chr>
1 345 mal man
2 346 male man
3 347 nonbinary non-binary
4 348 trans transgender
5 349 feamle woman
6 350 f woman
7 351 I'm a man I'm a man
Return Recode