EVOLUTION-MANAGER
Edit File: partial_factor.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: Partially specify a factor</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 partial_factor {vctrs}"><tr><td>partial_factor {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Partially specify a factor</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>This special class can be passed as a <code>ptype</code> in order to specify that the result should be a factor that contains at least the specified levels. </p> <h3>Usage</h3> <pre> partial_factor(levels = character()) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>levels</code></td> <td> <p>Character vector of labels.</p> </td></tr> </table> <h3>Examples</h3> <pre> # Assert that `x` is a factor vec_assert(factor("x"), partial_factor()) # Testing with `factor()` is too strict, # because it tries to match the levels exactly # rather than learning them from the data. try(vec_assert(factor("x"), factor())) # You can also enforce a minimum set of levels try(vec_assert(factor("x"), partial_factor("y"))) vec_assert(factor(c("x", "y")), partial_factor("y")) pf <- partial_factor(levels = c("x", "y")) pf vec_ptype_common(factor("v"), factor("w"), .ptype = pf) </pre> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>