recode_gender matches uncleaned gender responses to cleaned list using an inbuilt or custom dictionary.

recode_gender(gender = gender, dictionary = gendercoder::broad, fill = FALSE)

Arguments

gender

a character vector of gender responses for recoding

dictionary

a list that contains gender responses and their replacement values. A built-in dictionary broad is used by default if an alternative dictionary is not supplied.

fill

logical indicating if gender responses that are not found in dictionary should be filled with the uncleaned values during recoding

Value

a character vector of recoded genders

Examples

if (FALSE) { 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) ) df %>% mutate(recoded_gender = recode_gender(gender, dictionary = broad, fill = TRUE )) }