isValidAs {tractor.base}R Documentation

Check whether an object can be coerced to a specified mode

Description

Check whether an object can be coerced to a specified mode.

Usage

isValidAs(value, mode)

Arguments

value Any object.
mode A mode name, given as a character vector of length one.

Value

TRUE if all elements of the specified value can be successfully coerced to the given mode. FALSE otherwise.

Author(s)

Jon Clayden

See Also

mode

Examples

isValidAs("1.2", "double")  # TRUE
isValidAs("1.2", "integer")  # TRUE, although the value will be truncated
isValidAs(c(7,9,11), "double")  # TRUE
isValidAs("text", "double")  # FALSE

[Package tractor.base version 1.3.0 Index]