EVOLUTION-MANAGER
Edit File: charmatch.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: Partial String Matching</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 charmatch {base}"><tr><td>charmatch {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Partial String Matching</h2> <h3>Description</h3> <p><code>charmatch</code> seeks matches for the elements of its first argument among those of its second. </p> <h3>Usage</h3> <pre> charmatch(x, table, nomatch = NA_integer_) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>the values to be matched: converted to a character vector by <code><a href="character.html">as.character</a></code>. <a href="LongVectors.html">Long vectors</a> are supported.</p> </td></tr> <tr valign="top"><td><code>table</code></td> <td> <p>the values to be matched against: converted to a character vector. <a href="LongVectors.html">Long vectors</a> are not supported.</p> </td></tr> <tr valign="top"><td><code>nomatch</code></td> <td> <p>the (integer) value to be returned at non-matching positions.</p> </td></tr> </table> <h3>Details</h3> <p>Exact matches are preferred to partial matches (those where the value to be matched has an exact match to the initial part of the target, but the target is longer). </p> <p>If there is a single exact match or no exact match and a unique partial match then the index of the matching value is returned; if multiple exact or multiple partial matches are found then <code>0</code> is returned and if no match is found then <code>nomatch</code> is returned. </p> <p><code>NA</code> values are treated as the string constant <code>"NA"</code>. </p> <h3>Value</h3> <p>An integer vector of the same length as <code>x</code>, giving the indices of the elements in <code>table</code> which matched, or <code>nomatch</code>. </p> <h3>Author(s)</h3> <p>This function is based on a C function written by Terry Therneau. </p> <h3>See Also</h3> <p><code><a href="pmatch.html">pmatch</a></code>, <code><a href="match.html">match</a></code>. </p> <p><code><a href="startsWith.html">startsWith</a></code> for another matching of initial parts of strings; <code><a href="grep.html">grep</a></code> or <code><a href="grep.html">regexpr</a></code> for more general (regexp) matching of strings. </p> <h3>Examples</h3> <pre> charmatch("", "") # returns 1 charmatch("m", c("mean", "median", "mode")) # returns 0 charmatch("med", c("mean", "median", "mode")) # returns 2 </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>