Learn R Programming

tractor.base (version 1.1.0)

isValidAs: 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.

See Also

mode

Examples

Run this code
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

Run the code above in your browser using DataLab