Description Usage Arguments Details Value See Also Examples
View source: R/check-annotation-values.R
Checks if values are coercible to a given class. Because of inconsistencies
in R's built-in coercion functions (e.g.
as.numeric() warns when it
introduces NAs but
as.integer() will silently
remove decimal places from numeric inputs) we check only for the specific
coercions we want to allow, primarily allowing numeric, integer, or logical
values to be considered valid even when the required type is character.
Vector of values to check
Class of interest
This function is mainly in place so that we can automatically allow numeric read lengths, pH values, etc., which are defined as strings in our annotation vocabulary but can reasonably be numbers.
Additionally, this function will return
TRUE if the values are integers and
the desired class is numeric, and will return
TRUE if the values are
numeric but are whole numbers.
2.0 is considered coercible to integer, but
2.1 is not.
It will also allow the following capitalizations of boolean values: true, True, TRUE, false, False, FALSE. These are all treated as valid booleans by Synapse.
This function will not affect validation of enumerated values, regardless of their class. It is only used when validating annotations that have a required type but no enumerated values.
Boolean value; TRUE if
values are coercible to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Not run because function is not exported ## Not run: # Coercible: can_coerce(1, "character") can_coerce(TRUE, "character") can_coerce(1L, "character") can_coerce(1L, "numeric") can_coerce(1.0, "integer") # Not coercible: can_coerce("foo", "numeric") can_coerce("foo", "logical") can_coerce(2.5, "integer") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.