Description Usage Arguments Value Note See Also Examples
Coerce values in a safe, non-destructive and consistent way.
1 2 | coerce_safe(object, class, alert = stop, ..., alert_irreversible = alert,
alert_na = alert)
|
object |
to be coerced |
class |
character; class to which |
alert |
function to use to raise exceptions: (Default: |
... |
unused |
alert_irreversible |
function to raise alert when coercion is not reversible. See Details. |
alert_na |
function to raise when
Safe means that coercison:
By default, |
object
coerced to class
but ensured that there has been no loss in data
and no additional Missonve values introduced.
There must be a as
method to the reverse coercion for this function to work.
methods::as 'coercion::try_as()“
1 2 3 4 5 6 | ## Not run:
# Error
coerce_safe(1.01, "integer") # 1.01 != 1
coerce_safe( c("1","2","a"), "integer" )
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.