Description Usage Arguments Examples
to_logical
is designed for the situation where you have categorical data
(perhaps from a survey, or direct user input) that represents TRUE/FALSE values as something
other than TRUE/FALSE - "Yes", "No", "None", "Y" or "False", say. With to_logical
you can easily convert a vector of these values into an actual, logical vector, using
either a predefined set of accepted TRUE or FALSE equivalents, or a set you specify
yourself.
1 2 | to_logical(x, language = "en", custom_true = character(),
custom_false = character())
|
x |
a vector of categorical TRUE/FALSE/NA values. |
language |
the language to use. See |
custom_true |
a vector of values to consider, in addition to the ones
|
custom_false |
a vector of values to consider, in addition to the ones
|
1 2 3 4 5 6 7 | # A very simple example using the pre-known true and false equivalents
categorical_values <- c("true","t","y","yes","f","no","1")
to_logical(categorical_values)
# Use a custom specifier
categorical_values <- c("NA","NA","NA","NA","NA","NA","NA","NA","Batman")
to_logical(categorical_values, custom_true = c("Batman"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.