Or, to use the correct term, you want to coerce the variable from one class into another. To cover this briefly, coercing text to logical data is pretty intuitive: you use the as.logical() function, a...Or, to use the correct term, you want to coerce the variable from one class into another. To cover this briefly, coercing text to logical data is pretty intuitive: you use the as.logical() function, and the character strings "T", "TRUE", "True" and "true" all convert to the logical value of TRUE. When you go back the other way using as.character(), TRUE converts to "TRUE" and FALSE converts to "FALSE". Converting numbers to logicals – again using as.logical() – is straightforward.