This function dichotomizes (0/1) a variable by applying a function to it and checking whether each element equals the function's return value.
Arguments
- df
data.frame
- vars
(character) variable names to dichotomize
- value_fn
function that returns desired value for
1(defaultmax())- na.rm
(logical) whether to remove NAs before applying
value_fn(defaultTRUE)- ...
(optional) additional arguments passed to
value_fn