EVOLUTION-MANAGER
Edit File: maybe_lossy_cast.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Lossy cast error</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for maybe_lossy_cast {vctrs}"><tr><td>maybe_lossy_cast {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Lossy cast error</h2> <h3>Description</h3> <p><a href="https://lifecycle.r-lib.org/articles/stages.html#experimental"><img src="../help/figures/lifecycle-experimental.svg" alt='[Experimental]' /></a> </p> <p>By default, lossy casts are an error. Use <code>allow_lossy_cast()</code> to silence these errors and continue with the partial results. In this case the lost values are typically set to <code>NA</code> or to a lower value resolution, depending on the type of cast. </p> <p>Lossy cast errors are thrown by <code>maybe_lossy_cast()</code>. Unlike functions prefixed with <code>stop_</code>, <code>maybe_lossy_cast()</code> usually returns a result. If a lossy cast is detected, it throws an error, unless it's been wrapped in <code>allow_lossy_cast()</code>. In that case, it returns the result silently. </p> <h3>Usage</h3> <pre> maybe_lossy_cast( result, x, to, lossy = NULL, locations = NULL, ..., loss_type = c("precision", "generality"), x_arg, to_arg, call = caller_env(), details = NULL, message = NULL, class = NULL, .deprecation = FALSE ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>result</code></td> <td> <p>The result of a potentially lossy cast.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>Vectors to cast.</p> </td></tr> <tr valign="top"><td><code>to</code></td> <td> <p>Type to cast to.</p> </td></tr> <tr valign="top"><td><code>lossy</code></td> <td> <p>A logical vector indicating which elements of <code>result</code> were lossy. </p> <p>Can also be a single <code>TRUE</code>, but note that <code>locations</code> picks up locations from this vector by default. In this case, supply your own location vector, possibly empty.</p> </td></tr> <tr valign="top"><td><code>locations</code></td> <td> <p>An optional integer vector giving the locations where <code>x</code> lost information.</p> </td></tr> <tr valign="top"><td><code>..., class</code></td> <td> <p>Only use these fields when creating a subclass.</p> </td></tr> <tr valign="top"><td><code>loss_type</code></td> <td> <p>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).</p> </td></tr> <tr valign="top"><td><code>x_arg</code></td> <td> <p>Argument name for <code>x</code>, used in error messages to inform the user about the locations of incompatible types (see <code><a href="vctrs-conditions.html">stop_incompatible_type()</a></code>).</p> </td></tr> <tr valign="top"><td><code>to_arg</code></td> <td> <p>Argument name <code>to</code> used in error messages to inform the user about the locations of incompatible types (see <code><a href="vctrs-conditions.html">stop_incompatible_type()</a></code>).</p> </td></tr> <tr valign="top"><td><code>call</code></td> <td> <p>The execution environment of a currently running function, e.g. <code>caller_env()</code>. The function will be mentioned in error messages as the source of the error. See the <code>call</code> argument of <code><a href="../../rlang/html/abort.html">abort()</a></code> for more information.</p> </td></tr> <tr valign="top"><td><code>details</code></td> <td> <p>Any additional human readable details.</p> </td></tr> <tr valign="top"><td><code>message</code></td> <td> <p>An overriding message for the error. <code>details</code> and <code>message</code> are mutually exclusive, supplying both is an error.</p> </td></tr> <tr valign="top"><td><code>.deprecation</code></td> <td> <p>If <code>TRUE</code>, the error is downgraded to a deprecation warning. This is useful for transitioning your class to a stricter conversion scheme. The warning advises your users to wrap their code with <code>allow_lossy_cast()</code>.</p> </td></tr> </table> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>