| Line 6... |
Line 6... |
| 6 |
\name{Extract.data.frame}
|
6 |
\name{Extract.data.frame}
|
| 7 |
\alias{[.data.frame}
|
7 |
\alias{[.data.frame}
|
| 8 |
\alias{[[.data.frame}
|
8 |
\alias{[[.data.frame}
|
| 9 |
\alias{[<-.data.frame}
|
9 |
\alias{[<-.data.frame}
|
| 10 |
\alias{[[<-.data.frame}
|
10 |
\alias{[[<-.data.frame}
|
| - |
|
11 |
\alias{$.data.frame}
|
| 11 |
\alias{$<-.data.frame}
|
12 |
\alias{$<-.data.frame}
|
| 12 |
\title{Extract or Replace Parts of a Data Frame}
|
13 |
\title{Extract or Replace Parts of a Data Frame}
|
| 13 |
\description{
|
14 |
\description{
|
| 14 |
Extract or replace subsets of data frames.
|
15 |
Extract or replace subsets of data frames.
|
| 15 |
}
|
16 |
}
|
| 16 |
\usage{
|
17 |
\usage{
|
| 17 |
\method{[}{data.frame}(x, i, j, drop = )
|
18 |
\method{[}{data.frame}(x, i, j, drop = )
|
| 18 |
\method{[}{data.frame}(x, i, j) <- value
|
19 |
\method{[}{data.frame}(x, i, j) <- value
|
| 19 |
\method{[[}{data.frame}(x, ..., exact = TRUE)
|
20 |
\method{[[}{data.frame}(x, ..., exact = TRUE)
|
| 20 |
\method{[[}{data.frame}(x, i, j) <- value
|
21 |
\method{[[}{data.frame}(x, i, j) <- value
|
| - |
|
22 |
\method{$}{data.frame}(x, name)
|
| 21 |
\method{$}{data.frame}(x, name) <- value
|
23 |
\method{$}{data.frame}(x, name) <- value
|
| 22 |
}
|
24 |
}
|
| 23 |
\arguments{
|
25 |
\arguments{
|
| 24 |
\item{x}{data frame.}
|
26 |
\item{x}{data frame.}
|
| 25 |
|
27 |
|
| Line 48... |
Line 50... |
| 48 |
Data frames can be indexed in several modes. When \code{[} and
|
50 |
Data frames can be indexed in several modes. When \code{[} and
|
| 49 |
\code{[[} are used with a single vector index (\code{x[i]} or
|
51 |
\code{[[} are used with a single vector index (\code{x[i]} or
|
| 50 |
\code{x[[i]]}), they index the data frame as if it were a list. In
|
52 |
\code{x[[i]]}), they index the data frame as if it were a list. In
|
| 51 |
this usage a \code{drop} argument is ignored, with a warning.
|
53 |
this usage a \code{drop} argument is ignored, with a warning.
|
| 52 |
|
54 |
|
| 53 |
There is no \code{data.frame} method for \code{$}, so \code{x$name}
|
55 |
The \code{data.frame} method for \code{$}, treats \code{x} as a
|
| 54 |
uses the default method which treats \code{x} as a list. There is a
|
56 |
list, except that (as of R-3.1.0) partial matching of \code{name} to
|
| 55 |
replacement method which checks \code{value} for the correct number
|
57 |
the names of \code{x} will generate a warning; this may become an
|
| 56 |
of rows, and replicates it if necessary.
|
58 |
error in future versions. The replacement method checks
|
| - |
|
59 |
\code{value} for the correct number of rows, and replicates it if
|
| - |
|
60 |
necessary.
|
| 57 |
|
61 |
|
| 58 |
When \code{[} and \code{[[} are used with two indices (\code{x[i, j]}
|
62 |
When \code{[} and \code{[[} are used with two indices (\code{x[i, j]}
|
| 59 |
and \code{x[[i, j]]}) they act like indexing a matrix: \code{[[} can
|
63 |
and \code{x[[i, j]]}) they act like indexing a matrix: \code{[[} can
|
| 60 |
only be used to select one element. Note that for each selected
|
64 |
only be used to select one element. Note that for each selected
|
| 61 |
column, \code{xj} say, typically (if it is not matrix-like), the
|
65 |
column, \code{xj} say, typically (if it is not matrix-like), the
|