Rev 38792 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{head}\alias{head}\alias{head.default}\alias{head.data.frame}\alias{head.function}\alias{head.matrix}\alias{tail}\alias{tail.default}\alias{tail.data.frame}\alias{tail.function}\alias{tail.matrix}\title{Return the First or Last Part of an Object}\description{Returns the first or last parts of a vector, matrix, data frame or function.Since \code{head()} and \code{tail()} are generic functions, they mayalso have been extended to other classes.}\usage{head(x, \dots)\method{head}{default}(x, n = 6, \dots)\method{head}{data.frame}(x, n = 6, \dots)\method{head}{matrix}(x, n = 6, \dots)\method{head}{function}(x, n = 6, \dots)tail(x, \dots)\method{tail}{default}(x, n = 6, \dots)\method{tail}{data.frame}(x, n = 6, \dots)\method{tail}{matrix}(x, n = 6, addrownums = TRUE, \dots)\method{tail}{function}(x, n = 6, \dots)}\arguments{\item{x}{an object}\item{n}{a single integer. If positive, size for the resultingobject: number of elements for a vector (including lists), rows fora matrix or data frame or lines for a function. If negative, all butthe \code{n} last/first number of elements of \code{x}.}\item{addrownums}{if there are no row names, create them from the rownumbers.}\item{\dots}{arguments to be passed to or from other methods.}}\details{For matrices and data frames, \code{head()} (\code{tail()}) returnsthe first (last) \code{n} rows when \code{n > 0} or all but thelast (first) \code{n} rows when \code{n < 0}. For functions, thelines of the deparsed function are returned as character strings.If a matrix has no row names, then \code{tail()} will add row names ofthe form \code{"[n,]"} to the result, so that it looks similar to thelast lines of \code{x} when printed. Setting \code{addrownums =FALSE} suppresses this behaviour.}\value{An object (usually) like \code{x} but generally smaller.}\author{Patrick Burns, improved and corrected by R-Core. Negative argumentadded by Vincent Goulet.}\examples{head(letters)head(letters, n = -6)head(freeny.x, n = 10)head(freeny.y)tail(letters)tail(letters, n = -6)tail(freeny.x)tail(freeny.y)tail(library)}\keyword{ manip }