Title: | Convert categorical representations of logicals to actual logicals |
---|---|
Description: | Survey systems and other third-party data sources commonly use non- standard representations of logical values when it comes to qualitative data - "Yes", "No" and "N/A", say. batman is a package designed to seamlessly convert these into logicals. It is highly localised, and contains equivalents to boolean values in languages including German, French, Spanish, Italian, Turkish, Chinese and Polish. |
Authors: | Oliver Keyes [aut, cre], Ruben C. Arslan [ctb], Christopher Akiki [ctb], Mine Cetinkaya-Rundel [ctb], Peter Meissner [ctb], Ilaria Prosdocimi [ctb], Thomas Leeper [ctb], Amy Lee [ctb], Adolfo Álvarez [ctb] |
Maintainer: | Oliver Keyes <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2024-10-31 16:32:42 UTC |
Source: | https://github.com/ironholds/batman |
Survey systems and other third-party data sources commonly use non-standard representations of logical values when it comes to qualitative data - "Yes", "No" and "N/A", say. batman is a package designed to seamlessly convert these into actual logical values.
to_logical
A dataset containing the equivalents of TRUE or FALSE in categorical or user-submitted data, localised to various languages
categorical_booleans
categorical_booleans
A data.frame of three columns:
a two-letter language code vector of equivalents to TRUE;
the actual categorical variable in that language;
the value (TRUE or FALSE) that cat
represents.
to_logical
, which uses this dataset, and
get_languages
to see what languages are available.
retrieves a list of language codes for languages
supported by the language
parameter in to_logical
.
get_languages()
get_languages()
categorical_booleans
, the underlying dataset,
or to_logical
, which uses that dataset.
get_languages() # [1] "en"
get_languages() # [1] "en"
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.
to_logical(x, language = "en", custom_true = character(), custom_false = character())
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
|
# 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, too categorical_values <- c("NA","NA","NA","NA","NA","NA","NA","NA","Batman") to_logical(categorical_values, custom_true = c("Batman"))
# 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, too categorical_values <- c("NA","NA","NA","NA","NA","NA","NA","NA","Batman") to_logical(categorical_values, custom_true = c("Batman"))