View source: R/logical_to_yes_no.R
logical_to_yes_no | R Documentation |
Function to convert a logical vector to a "Yes/No" vector.
logical_to_yes_no(x, as_factor = TRUE, na_as_false = FALSE)
x |
Logical vector |
as_factor |
Should the return be a factor? |
na_as_false |
Should missing elements ( |
Ordered factor or character vector.
Stuart K. Grange
# A vector
x <- c(TRUE, TRUE, TRUE, FALSE, TRUE, NA, FALSE, TRUE, TRUE, TRUE)
# To yes/no
logical_to_yes_no(x)
# Replace NAs with FALSE
logical_to_yes_no(x, na_as_false = TRUE)
# As a character vector
logical_to_yes_no(x, as_factor = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.