\Header{Extract}{Extract or Replace Parts of an Object}
\alias{\$}{Extract}
\alias{\$<\Rdash}{Extract}
\alias{Subscript}{Extract}
\alias{[}{Extract}
\methalias{[.data.frame}{Extract}
\methalias{[.factor}{Extract}
\methalias{[.formula}{Extract}
\methalias{[.noquote}{Extract}
\methalias{[.ts}{Extract}
\alias{[<\Rdash}{Extract}
\methalias{[<\Rdash.data.frame}{Extract}
\methalias{[<\Rdash.factor}{Extract}
\methalias{[<\Rdash.noquote}{Extract}
\alias{[[}{Extract}
\methalias{[[.data.frame}{Extract}
\alias{[[<\Rdash}{Extract}
\methalias{[[<\Rdash.data.frame}{Extract}
\keyword{array}{Extract}
\keyword{list}{Extract}
\begin{Description}\relax
Operators act on vectors, arrays, dataframes and lists to extract or
replace subsets.\end{Description}
\begin{Usage}
\begin{verbatim}
x[i]
x[i, j, ...]
x[i, j, ... , drop=TRUE]
x[[i]]
x[[i, j, ...]]
x$name
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{i,j,name}] elements to extract or replace
\item[\code{drop}] For data frames, matrices, and arrays.  If \code{TRUE} the
result is coerced to the lowest possible dimension (see examples
below).
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If one of these expressions appears on the left side of an assignment
then that part of \code{x} is set to the value of the right hand side
of the assignment.

These operators are generic. You can write methods to handle subsetting
of specific classes of data.

The \code{[[} operator requires all relevant subscripts be supplied.
With the \code{[} operator a comma separated blank indicates that all
entries in that dimension are selected.

When \code{[.data.frame} is used for subsetting rows of a
\code{\Link{data.frame}}, it returns a dataframe with unique row names,
using \code{\Link{make.names}( * , unique = TRUE)}, see the \code{swiss}
example below.

When operating on a list, the \code{[[} operator gives the specified
element of the list while the \code{[} operator returns a list with
the specified element(s) in it.

The operators \code{\$} and \code{\$<-} do not evaluate their second
argument. It is translated to a string and that string is used to
locate the correct component of the first argument.\end{Details}
\begin{SeeAlso}\relax
\code{\Link{list}}, \code{\Link{array}}, \code{\Link{matrix}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- 1:12; m <- matrix(1:6,nr=2); li <- list(pi=pi, e = exp(1))
x[10]                 # the tenth element of x
m[1,]                 # the first row of matrix m
m[1, , drop = FALSE]  # is a 1-row matrix
li[[1]]               # the first element of list li
y <- list(1,2,a=4,5)
y[c(3,4)]             # a list containing elements 3 and 4 of y
y$a                   # the element of y named a

data(swiss)
swiss[ c(1, 1:2), ]   # duplicate row, unique row names
\end{ExampleCode}
\end{Examples}

