Package 'gendercoder'

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-12-13 06:28:46 UTC
Source: https://github.com/ropensci/gendercoder

Help Index


fewlevels_en

Description

A English dictionary for the recode_gender function that has fewer levels


gendercoder: A Package for Recoding Freetext Gender Data

Description

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?"


manylevels_en

Description

A English dictionary for the recode_gender function that has many levels


recode_gender

Description

recode_gender matches uncleaned gender responses to cleaned list using an built-in or custom dictionary.

Usage

recode_gender(
  gender = gender,
  dictionary = gendercoder::manylevels_en,
  retain_unmatched = FALSE
)

Arguments

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 manylevels_en is used by default if an alternative dictionary is not supplied.

retain_unmatched

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

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
))

sample

Description

A sample data.frame of free text gender in English for testing and demonstration