Title: | Recodes Sex/Gender Descriptions into a Standard Set |
---|---|
Description: | Provides functions and dictionaries for recoding of freetext gender responses into more consistent categories. |
Authors: | Yaoxiang Li [aut, cre] , Jennifer Beaudry [aut] , Emily Kothe [aut] , Felix Singleton Thorn [aut] , Rhydwyn McGuire [aut], Nicholas Tierney [aut] , Mathew Ling [aut] , Julia Silge [rev] (Julia reviewed the package (v. 0.0.0.9000) for rOpenSci, see <https://github.com/ropensci/software-review/issues/435>), Elin Waring [rev] (Elin reviewed the package (v. 0.0.0.9000) for rOpenSci, see <https://github.com/ropensci/software-review/issues/435>) |
Maintainer: | Yaoxiang Li <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-13 05:44:28 UTC |
Source: | https://github.com/ropensci/gendercoder |
Provides dictionaries and a function recode_gender
to allow for easy automatic coding of common variations in free text
responses to the question "What is your gender?"
recode_gender
matches uncleaned gender responses to cleaned list using
an built-in or custom dictionary.
recode_gender( gender = gender, dictionary = gendercoder::manylevels_en, retain_unmatched = FALSE )
recode_gender( gender = gender, dictionary = gendercoder::manylevels_en, retain_unmatched = FALSE )
gender |
a character vector of gender responses for recoding |
dictionary |
a list that the contains gender responses and their
replacement values. A built-in dictionary |
retain_unmatched |
logical indicating if gender responses that are not found in dictionary should be filled with the uncleaned values during recoding |
a character vector of recoded genders
df <- data.frame( stringsAsFactors = FALSE, gender = c("male", "MALE", "mle", "I am male", "femail", "female", "enby"), age = c(34L, 37L, 77L, 52L, 68L, 67L, 83L) ) dplyr::mutate(df, recoded_gender = recode_gender(gender, dictionary = manylevels_en, retain_unmatched = TRUE ))
df <- data.frame( stringsAsFactors = FALSE, gender = c("male", "MALE", "mle", "I am male", "femail", "female", "enby"), age = c(34L, 37L, 77L, 52L, 68L, 67L, 83L) ) dplyr::mutate(df, recoded_gender = recode_gender(gender, dictionary = manylevels_en, retain_unmatched = TRUE ))