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] |
Maintainer: | Yaoxiang Li <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-08-15 05:38:35 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 ))