Create recoded gender column
clean_gender.Rd
This function takes a column of gender values and, in a new column, returns the categorized values included in gender_walk.
Arguments
- x
Data.frame containing gender data
- var
Original variable containing gender data. Must be specified
- new_var
Name of new gender variable. Defaults to gender_clean
Examples
head(test_data) %>% clean_gender(gender) %>% select(gender, gender_clean)
#> The following values are not in the gender walk dictionary and have been assigned a value of NA in the newly created variable:
#> 1
#> 2
#>
#> # A tibble: 6 × 2
#> gender gender_clean
#> <dbl> <chr>
#> 1 1 NA
#> 2 2 NA
#> 3 2 NA
#> 4 2 NA
#> 5 2 NA
#> 6 1 NA