encode_bin_cat_vec {eHDPrep} | R Documentation |
Encode a categorical vector with binary categories
Description
In a character vector, converts binary categories to factor levels.
Usage
encode_bin_cat_vec(x, values = NULL, numeric_out = FALSE)
Arguments
x |
non-numeric input vector |
values |
Optional named vector of user-defined values for binary values
using |
numeric_out |
If true, numeric vector is returned. If false, factor is returned. |
Details
Binary categories to convert can be specified with a named character vector,
specified in values
. The syntax of the named vector is:
negative_finding = positive_finding
. If values
is not
provided, the default list will be used: "No"="Yes", "No/unknown" =
"Yes", "no/unknown" = "Yes", "Non-user" = "User", "Never" = "Ever", "WT" =
"MT"
.
Value
Factor with false finding encoded as 1 and true finding encoded as
2. Alternatively, numeric vector if numeric_out
parameter is
TRUE
.