head
Get the First or Last Part of an Object

### Description

Returns either the first (head) or last (tail) parts of a vector, matrix, data frame, table or function.

### Usage

    head(x, ...)
    ## Default S3 method:
    head(x, n = 6L, ...)
    ## S3 method for class 'array':
    head(x, n = 6L, ...)
    ## S3 method for class 'data.frame':
    head(x, n = 6L, ...)
    ## S3 method for class 'matrix':
    head(x, n = 6L, ...)
    ## S3 method for class 'function':
    head(x, n = 6L, ...)
    tail(x, ...)
    ## Default S3 method:
    head(x, n = 6L, ...)
    ## S3 method for class 'array':
    head(x, n = 6L, keepnums = TRUE, addrownums, ...)
    ## S3 method for class 'data.frame':
    head(x, n = 6L, keepnums = TRUE, addrownums, ...)
    ## S3 method for class 'matrix':
    head(x, n = 6L, keepnums = TRUE, addrownums, ...)
    ## S3 method for class 'table':
    head(x, n = 6L, keepnums = TRUE, addrownums, ...)
    ## S3 method for class 'function':
    head(x, n = 6L, keepnums = TRUE, addrownums, ...)

### Arguments

x | an object.
n | If x is a vector or a function, a non-negative integer indicating how many elements of the vector or lines of the function to return or a negative integer indicating how many not to return. If x is an array, a table, or a data.frame or any object for which dim(x) is not NULL, then n may be a vector of integers specifying how many slices of each dimension to return (NA means all slices in that dimension). If the length of n is less than length(dim(x)) then n will be padded with NA to the length(dim(x)).
keepnums | A logical value used by the methods for objects with dimensions. If TRUE, tail will attach dimnames entries for the shortened dimensions to indicate where the rows, columns, etc. came from in x. If a dimension has a dimnames entry, keepnums will not alter it.
addrownames | A defunct name for the keepnums argument. If you use it, you will be warned to use keepnums instead.
... | additional arguments passed to the head or tail method.

### Details

head and tail return (respectively) the first or last n (or all but the last or first -n for negative n) elements of a vector, rows, column, etc., of a data frame, table or array, or lines of a function.
Value
returns an object of roughly the same type of the input object x, unless x is a function. If x is a function, the returned value is a vector of strings that have line numbers at the beginning of each string.
See Also
format, sprintf, str.
Examples

    head(objects())
    head(matrix(1:16,4), n=2)
    head(data.frame(x=1:10,y=101:110), n=-3)
    tail(matrix(1:16,4,4), n=2)
    tail(matrix(1:16,4), n=c(-2,3))
    tail(matrix(1:16,4), n=c(NA,3))
    tail(data.frame(x=1:10,y=101:110), n=-3)

Package utils version 6.1.5-18
Package Index