EVOLUTION-MANAGER
Edit File: canCoerce.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: Can an Object be Coerced to a Certain S4 Class?</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 canCoerce {methods}"><tr><td>canCoerce {methods}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Can an Object be Coerced to a Certain S4 Class?</h2> <h3>Description</h3> <p>Test if an object can be coerced to a given S4 class. Maybe useful inside <code>if()</code> to ensure that calling <code>as(object, Class)</code> will find a method. </p> <h3>Usage</h3> <pre> canCoerce(object, Class) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>object</code></td> <td> <p>any <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object, typically of a formal S4 class.</p> </td></tr> <tr valign="top"><td><code>Class</code></td> <td> <p>an S4 class (see <code><a href="findClass.html">isClass</a></code>).</p> </td></tr> </table> <h3>Value</h3> <p>a scalar logical, <code>TRUE</code> if there is a <code>coerce</code> method (as defined by e.g. <code><a href="setAs.html">setAs</a></code>) for the signature <code>(from = class(object), to = Class)</code>. </p> <h3>See Also</h3> <p><code><a href="as.html">as</a></code>, <code><a href="setAs.html">setAs</a></code>, <code><a href="getMethod.html">selectMethod</a></code>, <code><a href="setClass.html">setClass</a></code>, </p> <h3>Examples</h3> <pre> m <- matrix(pi, 2,3) canCoerce(m, "numeric") # TRUE canCoerce(m, "array") # TRUE </pre> <hr /><div style="text-align: center;">[Package <em>methods</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>