Skip to contents

Often True-False data is returned as a vector of Ys and Ns or 1s and 0s. These vectors often contain blanks or NAs that cannot, and should not, be converted into Falses. This function converts

  • "Y" –>> TRUE

  • "N" –>> FALSE

  • "Yes" –>> TRUE

  • "No" –>> FALSE

  • "1" –>> TRUE

  • "0" –>> FALSE

  • 1 –>> TRUE

  • 0 –>> FALSE

and leave blanks and NAs in the vector.

Usage

convert.YN2TF(YN.string)

Arguments

YN.string

string with "Yes", "No" indicators such as "Y", "N", "yes", "no", "1", or "0"

Value

logical vector

Examples

YN.string <- c("Y", "N", "1", "0", "yes", "no", NA, NA)
# [1]  TRUE FALSE  TRUE FALSE    NA    NA