The R Project SVN R

Rev

Rev 25600 | Rev 30448 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25600 Rev 27128
Line 9... Line 9...
9
\usage{
9
\usage{
10
subset(x, \dots)
10
subset(x, \dots)
11
 
11
 
12
\method{subset}{default}(x, subset, \dots)
12
\method{subset}{default}(x, subset, \dots)
13
 
13
 
14
\method{subset}{data.frame}(x, subset, select, \dots)
14
\method{subset}{data.frame}(x, subset, select, drop = FALSE, \dots)
15
}
15
}
16
\arguments{
16
\arguments{
17
  \item{x}{object to be subsetted.}
17
  \item{x}{object to be subsetted.}
18
  \item{subset}{logical expression.}
18
  \item{subset}{logical expression.}
19
  \item{select}{expression, indicating columns to select from a
19
  \item{select}{expression, indicating columns to select from a
20
    data frame.}
20
    data frame.}
-
 
21
  \item{drop}{passed on to \code{[} indexing operator.}
21
  \item{\dots}{further arguments to be passed to or from other methods.}
22
  \item{\dots}{further arguments to be passed to or from other methods.}
22
}
23
}
23
\details{
24
\details{
24
  For ordinary vectors, the result is simply
25
  For ordinary vectors, the result is simply
25
  \code{x[subset & !is.na(subset)]}.
26
  \code{x[subset & !is.na(subset)]}.
Line 33... Line 34...
33
  first replacing names in the selection expression with the
34
  first replacing names in the selection expression with the
34
  corresponding column numbers in the data frame and then using the
35
  corresponding column numbers in the data frame and then using the
35
  resulting integer vector to index the columns.  This allows the use
36
  resulting integer vector to index the columns.  This allows the use
36
  of the standard indexing conventions so that for example ranges of
37
  of the standard indexing conventions so that for example ranges of
37
  columns can be specified easily.
38
  columns can be specified easily.
-
 
39
 
-
 
40
  Setting \code{drop=TRUE} will drop unused levels from factors in a
-
 
41
  data frame. The default is to retain them.
38
}
42
}
39
\value{
43
\value{
40
  An object similar to \code{x} contain just the selected elements (for
44
  An object similar to \code{x} contain just the selected elements (for
41
  a vector), rows and columns (for a data frame), and so on.
45
  a vector), rows and columns (for a data frame), and so on.
42
}
46
}