Lossy cast error
By default, lossy casts are an error. Use allow_lossy_cast()
to
silence these errors and continue with the partial results. In this
case the lost values are typically set to NA
or to a lower value
resolution, depending on the type of cast.
Lossy cast errors are thrown by maybe_lossy_cast()
. Unlike
functions prefixed with stop_
, maybe_lossy_cast()
usually
returns a result. If a lossy cast is detected, it throws an error,
unless it's been wrapped in allow_lossy_cast()
. In that case, it
returns the result silently.
maybe_lossy_cast( result, x, to, lossy = NULL, locations = NULL, ..., loss_type = c("precision", "generality"), x_arg, to_arg, details = NULL, message = NULL, class = NULL, .deprecation = FALSE )
result |
The result of a potentially lossy cast. |
x |
Vectors |
to |
Type to cast to. |
lossy |
A logical vector indicating which elements of Can also be a single |
locations |
An optional integer vector giving the
locations where |
... |
Only use these fields when creating a subclass. |
loss_type |
The kind of lossy cast to be mentioned in error messages. Can be loss of precision (for instance from double to integer) or loss of generality (from character to factor). |
x_arg |
Argument names for |
to_arg |
Argument names for |
details |
Any additional human readable details. |
message |
An overriding message for the error. |
class |
Only use these fields when creating a subclass. |
.deprecation |
If |
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.