EVOLUTION-MANAGER
Edit File: strtoi.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: Convert Strings to Integers</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 strtoi {base}"><tr><td>strtoi {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Convert Strings to Integers</h2> <h3>Description</h3> <p>Convert strings to integers according to the given base using the C function <code>strtol</code>, or choose a suitable base following the C rules. </p> <h3>Usage</h3> <pre>strtoi(x, base = 0L)</pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a character vector, or something coercible to this by <code><a href="character.html">as.character</a></code>.</p> </td></tr> <tr valign="top"><td><code>base</code></td> <td> <p>an integer which is between 2 and 36 inclusive, or zero (default).</p> </td></tr> </table> <h3>Details</h3> <p>Conversion is based on the C library function <code>strtol</code>. </p> <p>For the default <code>base = 0L</code>, the base chosen from the string representation of that element of <code>x</code>, so different elements can have different bases (see the first example). The standard C rules for choosing the base are that octal constants (prefix <code>0</code> not followed by <code>x</code> or <code>X</code>) and hexadecimal constants (prefix <code>0x</code> or <code>0X</code>) are interpreted as base <code>8</code> and <code>16</code>; all other strings are interpreted as base <code>10</code>. </p> <p>For a base greater than <code>10</code>, letters <code>a</code> to <code>z</code> (or <code>A</code> to <code>Z</code>) are used to represent <code>10</code> to <code>35</code>. </p> <h3>Value</h3> <p>An integer vector of the same length as <code>x</code>. Values which cannot be interpreted as integers or would overflow are returned as <code><a href="NA.html">NA_integer_</a></code>. </p> <h3>See Also</h3> <p>For decimal strings <code><a href="integer.html">as.integer</a></code> is equally useful. </p> <h3>Examples</h3> <pre> strtoi(c("0xff", "077", "123")) strtoi(c("ffff", "FFFF"), 16L) strtoi(c("177", "377"), 8L) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>