EVOLUTION-MANAGER
Edit File: subset.data.table.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: Subsetting data.tables</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 subset.data.table {data.table}"><tr><td>subset.data.table {data.table}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Subsetting data.tables </h2> <h3>Description</h3> <p>Returns subsets of a <code>data.table</code>. </p> <h3>Usage</h3> <pre> ## S3 method for class 'data.table' subset(x, subset, select, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p><code>data.table</code> to subset. </p> </td></tr> <tr valign="top"><td><code>subset</code></td> <td> <p>logical expression indicating elements or rows to keep </p> </td></tr> <tr valign="top"><td><code>select</code></td> <td> <p>expression indicating columns to select from <code>data.table</code> </p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments to be passed to or from other methods </p> </td></tr> </table> <h3>Details</h3> <p>The <code>subset</code> argument works on the rows and will be evaluated in the <code>data.table</code> so columns can be referred to (by name) as variables in the expression. </p> <p>The <code>data.table</code> that is returned will maintain the original keys as long as they are not <code>select</code>-ed out. </p> <h3>Value</h3> <p>A <code>data.table</code> containing the subset of rows and columns that are selected. </p> <h3>See Also</h3> <p><code><a href="../../base/html/subset.html">subset</a></code> </p> <h3>Examples</h3> <pre> DT <- data.table(a=sample(c('a', 'b', 'c'), 20, replace=TRUE), b=sample(c('a', 'b', 'c'), 20, replace=TRUE), c=sample(20), key=c('a', 'b')) sub <- subset(DT, a == 'a') all.equal(key(sub), key(DT)) </pre> <hr /><div style="text-align: center;">[Package <em>data.table</em> version 1.14.4 <a href="00Index.html">Index</a>]</div> </body></html>