| reformat_sex | R Documentation |
Reformat a binary sex variable so
that it consists entirely of
values "Female", "Male",
and possibly NA and any values
included in except.
reformat_sex(x, except = NULL, factor = TRUE)
x |
A vector. |
except |
Values to exclude when reformatting. |
factor |
Whether the return value should be a factor. |
When parsing labels, reformat_sex()
ignores case: "FEMALE" and "fEmAlE"
are equivalent.
White space is removed from the beginning and end of labels.
reformat_sex() does not try to interpreting
numeric codes (eg 1, 2).
If factor is TRUE,
then reformat_age() returns a factor;
otherwise it returns a character vector.
age_labels(), reformat_age()
reformat_sex(c("F", "female", NA, "MALES"))
## values supplied for 'except'
reformat_sex(c("Fem", "Other", "Male", "M"),
except = c("Other", "Diverse"))
## return an ordinary character vector
reformat_sex(c("F", "female", NA, "MALES"),
factor = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.