## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup, echo = FALSE, message=FALSE---------------------------------------
df <- data.frame(
  gender = c("male", "enby", "womn", "mlae", "mann", "frau", "femme", "homme", "nin"),
  stringsAsFactors = FALSE
)

## ----example-data, message=FALSE----------------------------------------------
library(gendercoder)
df

## ----new-dictionary-----------------------------------------------------------
new_dictionary <- c(
  mann = "man", 
  frau = "woman", 
  femme = "woman", 
  homme = "man", 
  nin = "man")

new_dictionary_df <- df
new_dictionary_df$recoded_gender <- recode_gender(
  df$gender,
  dictionary = new_dictionary,
  retain_unmatched = TRUE
)
new_dictionary_df


## ----inline-augmentation------------------------------------------------------
inline_df <- df
inline_df$recoded_gender <- recode_gender(
  df$gender,
  dictionary = c(manylevels_en, new_dictionary),
  retain_unmatched = TRUE
)
inline_df

## ----stepped-augmentation-----------------------------------------------------
manylevels_plus <-  c(manylevels_en, new_dictionary)

stepped_df <- df
stepped_df$recoded_gender <- recode_gender(
  df$gender,
  dictionary = manylevels_plus,
  retain_unmatched = TRUE
)
stepped_df

## ----replacing-dictionaries, eval=FALSE---------------------------------------
# manylevels_en <-  manylevels_plus
# usethis::use_data(manylevels_en, overwrite = TRUE)

