internal function to make all "yes" answers equal to 1, and all "no" to 0. This for convenience of calculations later.

gds_binary(x, values = gds_values())

Arguments

x

vector of yes and no coding

values

named vector of 2 providing the coding for Yes and No answers c(Yes = 1, No = 2)

Value

vector of 0's and 1's

See also

Other gds_functions: gds_alter_values(), gds_compute_sum(), gds_values()

Examples

gds_binary(c(1,1,0,NA,1), gds_values(1,0))
#> [1]  0  0  1 NA  0
gds_binary(c("y","y","n",NA,"y"), gds_values(yes = "y", no = "n"))
#> [1]  0  0  1 NA  0