\HeaderA{head}{Return the First or Last Part of an Object}{head}
\methaliasA{head.data.frame}{head}{head.data.frame}
\methaliasA{head.default}{head}{head.default}
\methaliasA{head.function}{head}{head.function}
\methaliasA{head.matrix}{head}{head.matrix}
\aliasA{tail}{head}{tail}
\methaliasA{tail.data.frame}{head}{tail.data.frame}
\methaliasA{tail.default}{head}{tail.default}
\methaliasA{tail.function}{head}{tail.function}
\methaliasA{tail.matrix}{head}{tail.matrix}
\keyword{manip}{head}
\begin{Description}\relax
Returns the first or last parts of a vector, matrix, data frame or function.
\end{Description}
\begin{Usage}
\begin{verbatim}
head(x, ...)
## Default S3 method:
head(x, n = 6, ...)
## S3 method for class 'data.frame':
head(x, n = 6, ...)
## S3 method for class 'matrix':
head(x, n = 6, ...)

tail(x, ...)
## Default S3 method:
tail(x, n = 6, ...)
## S3 method for class 'data.frame':
tail(x, n = 6, ...)
## S3 method for class 'matrix':
tail(x, n = 6, addrownums = TRUE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an object
\item[\code{n}] size for the resulting object: number of elements for a
vector (including lists), rows for a matrix or data frame or
lines for a function.
\item[\code{addrownums}] if there are no row names, create them from the row numbers.
\item[\code{...}] arguments to be passed to or from other methods.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
For matrices and data frames, the first/last \code{n} rows are returned.
For functions, the first/last \code{n} lines of the deparsed function are
returned as character strings.

If a matrix has no row names, then \code{tail()} will add row names of
the form \code{"[n,]"} to the result, so that it looks similar to the last lines of \code{x}
when printed.  Setting \code{addrownums = FALSE} suppresses this behaviour.
\end{Details}
\begin{Value}
An object (usually) like \code{x} but generally smaller.
\end{Value}
\begin{Author}\relax
Patrick Burns, improved and corrected by R-Core
\end{Author}
\begin{Examples}
\begin{ExampleCode}
head(freeny.x, n = 10)
head(freeny.y)

tail(freeny.x)
tail(freeny.y)

tail(library)
\end{ExampleCode}
\end{Examples}

