Cast boolean values

types.castBoolean(format = "default", value, options = {
})

Arguments

format

no options (other than the default)

value

boolean to cast

options

specify additioanl true values or/and falsevalues

Details

In the physical representations of data where boolean values are represented with strings, the values set in trueValues and falseValues are to be cast to their logical representation as booleans. trueValues and falseValues are lists which can be customised to user need. The default values for these are in the additional properties section below.

The boolean field can be customised with these additional properties:

  • trueValues: ["true", "True", "TRUE", "1"]

  • falseValues: ["false", "False", "FALSE", "0"]

See also

Examples

types.castBoolean(format = "default", value = TRUE)
#> [1] TRUE
types.castBoolean(format = "default", value = "true")
#> [1] TRUE
types.castBoolean(format = "default", value = "1")
#> [1] TRUE
types.castBoolean(format = "default", value = "0")
#> [1] FALSE
# set options with additional true value types.castBoolean(format = "default", value = "yes", list(trueValues = list("yes")))
#> [1] TRUE
# set options with additional false value types.castBoolean(format = "default", value = "no", list(falseValues = list("no")))
#> [1] FALSE