head {utils} | R Documentation

## Return the First or Last Part of an Object

### Description

Returns the first or last parts of a vector, matrix, data frame or function.

### Usage

    head(x, ...)
    ## Default S3 method:
    head(x, n=6, ...)
    ## S3 method for class 'data.frame':
    head(x, n=6, ...)

    tail(x, ...)
    ## Default S3 method:
    tail(x, n=6, ...)
    ## S3 method for class 'data.frame':
    tail(x, n=6, ...)

### Arguments

`x` | an object
`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.
`...` | arguments to be passed to or from other methods.

### Details

For matrices and data frames, the first/last `n` rows are returned. For functions, the first/last `n` lines of the deparsed function are returned as character strings.

### Value

An object (usually) like `x` but generally smaller.

### Author(s)

Patrick Burns, improved and corrected by R-core

### Examples

    data(freeny)
    head(freeny.x, n=10)
    head(freeny.y)

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

    tail(library)

[Package Contents]