EVOLUTION-MANAGER
Edit File: bincode.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: Bin a Numeric Vector</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 .bincode {base}"><tr><td>.bincode {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Bin a Numeric Vector</h2> <h3>Description</h3> <p>Bin a numeric vector and return integer codes for the binning. </p> <h3>Usage</h3> <pre> .bincode(x, breaks, right = TRUE, include.lowest = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a numeric vector which is to be converted to integer codes by binning.</p> </td></tr> <tr valign="top"><td><code>breaks</code></td> <td> <p>a numeric vector of two or more cut points, sorted in increasing order.</p> </td></tr> <tr valign="top"><td><code>right</code></td> <td> <p>logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.</p> </td></tr> <tr valign="top"><td><code>include.lowest</code></td> <td> <p>logical, indicating if an ‘x[i]’ equal to the lowest (or highest, for <code>right = FALSE</code>) ‘breaks’ value should be included in the first (or last) bin.</p> </td></tr> </table> <h3>Details</h3> <p>This is a ‘barebones’ version of <code>cut.default(labels = FALSE)</code> intended for use in other functions which have checked the arguments passed. (Note the different order of the arguments they have in common.) </p> <p>Unlike <code><a href="cut.html">cut</a></code>, the <code>breaks</code> do not need to be unique. An input can only fall into a zero-length interval if it is closed at both ends, so only if <code>include.lowest = TRUE</code> and it is the first (or last for <code>right = FALSE</code>) interval. </p> <h3>Value</h3> <p>An integer vector of the same length as <code>x</code> indicating which bin each element falls into (the leftmost bin being bin <code>1</code>). <code>NaN</code> and <code>NA</code> elements of <code>x</code> are mapped to <code>NA</code> codes, as are values outside range of <code>breaks</code>. </p> <h3>See Also</h3> <p><code><a href="cut.html">cut</a></code>, <code><a href="tabulate.html">tabulate</a></code> </p> <h3>Examples</h3> <pre> ## An example with non-unique breaks: x <- c(0, 0.01, 0.5, 0.99, 1) b <- c(0, 0, 1, 1) .bincode(x, b, TRUE) .bincode(x, b, FALSE) .bincode(x, b, TRUE, TRUE) .bincode(x, b, FALSE, TRUE) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>