head {utils} R Documentation

Return the First or Last Part of an Object

Description


Returns the first or last parts of a vector, matrix, table, data frame or function.
Since head() and tail() are generic functions, they may also have been extended
to other classes.

Usage

head(x,
    n = 6);

Arguments

x

an object

n

a single integer. If positive or zero, 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. If negative, all but the n last/first number of elements of x. [as integer]

env

[as Environment]

Details

For matrices, 2-dim tables and data frames, head() (tail()) returns the first (last) n rows when n >= 0 or all but the last (first) n rows when n < 0. head.matrix() and tail.matrix() are exported. For functions, the lines of the deparsed function are returned as character strings.

If a matrix has no row names, Then tail() will add row names Of the form "[n,]" To the result, so that it looks similar To the last lines Of x When printed. Setting addrownums = False suppresses this behaviour.

Authors

SMRUCC genomics Institute

Value

An object (usually) like x but generally smaller. For ftable objects x, a transformed format(x).

clr value class

Examples


[Package utils version 2.33.856.6961 Index]