Package 'batman'

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

Help Index


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 actual logical values.

See Also

to_logical


TRUE/FALSE equivalents in categorical data for various languages

Description

A dataset containing the equivalents of TRUE or FALSE in categorical or user-submitted data, localised to various languages

Usage

categorical_booleans

Format

A data.frame of three columns:

language

a two-letter language code vector of equivalents to TRUE;

cat

the actual categorical variable in that language;

value

the value (TRUE or FALSE) that cat represents.

See Also

to_logical, which uses this dataset, and get_languages to see what languages are available.


Get language codes for batman-supported languages

Description

retrieves a list of language codes for languages supported by the language parameter in to_logical.

Usage

get_languages()

See Also

categorical_booleans, the underlying dataset, or to_logical, which uses that dataset.

Examples

get_languages()
# [1] "en"

Convert categorical representations of true/false values to a logical

Description

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.

Usage

to_logical(x, language = "en", custom_true = character(),
  custom_false = character())

Arguments

x

a vector of categorical TRUE/FALSE/NA values.

language

the language to use. See get_languages for the list of supported languages. If your language is not supported, you can use custom_true and custom_false to provide values.

custom_true

a vector of values to consider, in addition to the ones to_logical already recognises, TRUE. Empty by default. Note that the comparison code is case-insensitive, so there's no need to include (for example) both "ja" and "Ja".

custom_false

a vector of values to consider, in addition to the ones to_logical already recognises, FALSE. Empty by default; see the notes on case sensitivity above.

Examples

# 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"))