If the vector is a 0/1 vector, it is converted to a logical one TRUE/FALSE vector. This transformation is performed only if the vector contains only values 0, 1, or NA. If this is not the case returns the original variable. This transformation can be done on numeric, string, and factor vectors.

transform_01_to_ft(x)

Arguments

x

the vector to be tested and transformed.

Value

The transformed vector if a transformation is possible. If no transformation is possible, the original vector returned.

See also

Other vector calculations: academic_year(), clean_multiple_underscores(), interval_round(), month_name(), sum_0_1()

Other booleans: test_01()

Examples

vector <- c(0, 1, 0, 1, 1, 1, 0)
transform_01_to_ft(vector)
#> [1] FALSE  TRUE FALSE  TRUE  TRUE  TRUE FALSE