head()
and tail()
are generic
functions, they may also have been extended to other classes.head(x, …)
# S3 method for default
head(x, n = 6L, …)
# S3 method for data.frame
head(x, n = 6L, …)
# S3 method for matrix
head(x, n = 6L, …)
# S3 method for ftable
head(x, n = 6L, …)
# S3 method for table
head(x, n = 6L, …)
# S3 method for function
head(x, n = 6L, …)tail(x, …)
# S3 method for default
tail(x, n = 6L, …)
# S3 method for data.frame
tail(x, n = 6L, …)
# S3 method for matrix
tail(x, n = 6L, addrownums = TRUE, …)
# S3 method for ftable
tail(x, n = 6L, addrownums = FALSE, …)
# S3 method for table
tail(x, n = 6L, addrownums = TRUE, …)
# S3 method for function
tail(x, n = 6L, …)
n
last/first number of elements of x
.x
but generally smaller. For
ftable
objects x
, a transformed format(x)
.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.head(letters) head(letters, n = -6L) head(freeny.x, n = 10L) head(freeny.y) tail(letters) tail(letters, n = -6L) tail(freeny.x) tail(freeny.y) tail(library) head(stats::ftable(Titanic))
Run the code above in your browser using DataCamp Workspace