add_bin_labels: Reverse numeric conversion of binary vector

Description Usage Arguments Value Examples

View source: R/pre_processing.R

Description

Helper function to re-apply binary variable labels post-imputation.

Usage

1
add_bin_labels(x, one, zero, fast = TRUE)

Arguments

x

A numeric vector or column, scaled between 0 and 1

one

A character string, the label associated with binary value 1

zero

A character string, the label associated with binary value 0

fast

Boolean indicating whether to return binary value 1 if predicted probability >= 0.5 (TRUE), or take random draw using predicted probability as weighting.

Value

Vector of character strings corresponding to binary values

Examples

1
2
3
4
5
ex_bin <- c(1,0,0,1,1,0,0,1,0)
cat <- "cat"
dog <- "dog"

add_bin_labels(x = ex_bin, one = cat, zero = dog)

rMIDAS documentation built on Jan. 30, 2021, 9:05 a.m.