summaryrefslogtreecommitdiff
path: root/site/docs/1.5.1/api/R/subset.html
blob: f970e7a63340417c8e55f7720f70447f69d84124 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!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: Subset</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/languages/r.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head><body>

<table width="100%" summary="page for [[ {SparkR}"><tr><td>[[ {SparkR}</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>Subset</h2>

<h3>Description</h3>

<p>Return subsets of DataFrame according to given conditions
</p>


<h3>Usage</h3>

<pre>
## S4 method for signature 'DataFrame,numericOrcharacter'
x[[i]]

## S4 method for signature 'DataFrame,missing,ANY'
x[i, j, ..., drop = TRUE]

## S4 method for signature 'DataFrame,Column,ANY'
x[i, j, ..., drop = TRUE]

## S4 method for signature 'DataFrame'
subset(x, subset, select, ...)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
<p>A DataFrame</p>
</td></tr>
<tr valign="top"><td><code>subset</code></td>
<td>
<p>A logical expression to filter on rows</p>
</td></tr>
<tr valign="top"><td><code>select</code></td>
<td>
<p>expression for the single Column or a list of columns to select from the DataFrame</p>
</td></tr>
</table>


<h3>Value</h3>

<p>A new DataFrame containing only the rows that meet the condition with selected columns
</p>


<h3>See Also</h3>

<p>Other subsetting functions: <code><a href="select.html">$</a></code>,
<code><a href="select.html">$&lt;-</a></code>, <code><a href="select.html">select</a></code>,
<code><a href="select.html">select</a></code>,
<code><a href="select.html">select,DataFrame,Column-method</a></code>,
<code><a href="select.html">select,DataFrame,list-method</a></code>,
<code><a href="selectExpr.html">selectExpr</a></code>; <code><a href="filter.html">filter</a></code>,
<code><a href="filter.html">filter</a></code>, <code><a href="filter.html">where</a></code>,
<code><a href="filter.html">where</a></code>
</p>


<h3>Examples</h3>

<pre><code class="r">## Not run: 
##D   # Columns can be selected using `[[` and `[`
##D   df[[2]] == df[[&quot;age&quot;]]
##D   df[,2] == df[,&quot;age&quot;]
##D   df[,c(&quot;name&quot;, &quot;age&quot;)]
##D   # Or to filter rows
##D   df[df$age &gt; 20,]
##D   # DataFrame can be subset on both rows and Columns
##D   df[df$name == &quot;Smith&quot;, c(1,2)]
##D   df[df$age %in% c(19, 30), 1:2]
##D   subset(df, df$age %in% c(19, 30), 1:2)
##D   subset(df, df$age %in% c(19), select = c(1,2))
## End(Not run)
</code></pre>


<hr /><div style="text-align: center;">[Package <em>SparkR</em> version 1.5.1 <a href="00Index.html">Index</a>]</div>
</body></html>