isValidAs {tractor.base} | R Documentation |
Check whether an object can be coerced to a specified mode.
isValidAs(value, mode)
value |
Any object. |
mode |
A mode name, given as a character vector of length one. |
TRUE if all elements of the specified value
can be successfully coerced to the given mode
. FALSE otherwise.
Jon Clayden
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