headtail: Shows rows from the head and tail of a data frame or matrix.

View source: R/FSAUtils.R

headtailR Documentation

Shows rows from the head and tail of a data frame or matrix.

Description

Shows rows from the head and tail of a data frame or matrix.

Usage

headtail(x, n = 3L, which = NULL, addrownums = TRUE, ...)

Arguments

x

A data frame or matrix.

n

A single numeric that indicates the number of rows to display from each of the head and tail of structure.

which

A numeric or string vector that contains the column numbers or names to display. Defaults to showing all columns.

addrownums

If there are no row names for the MATRIX, then create them from the row numbers.

...

Arguments to be passed to or from other methods.

Value

A matrix or data.frame with 2*n rows.

Note

If n is larger than the number of rows in x then all of x is displayed.

Author(s)

Derek H. Ogle, DerekOgle51@gmail.com

See Also

peek

Examples

headtail(iris)
headtail(iris,10)
headtail(iris,which=c("Sepal.Length","Sepal.Width","Species"))
headtail(iris,which=grep("Sepal",names(iris)))
headtail(iris,n=200)

## Make a matrix for demonstration purposes only
miris <- as.matrix(iris[,1:4])
headtail(miris)
headtail(miris,10)
headtail(miris,addrownums=FALSE)
headtail(miris,10,which=2:4)

## Make a tbl_df type from tibble ... note how headtail()
## is not limited by the tbl_df restriction on number of
## rows to show (but head() is).
if (require(tibble)) {
  iris2 <- as_tibble(iris)
  class(iris2)
  headtail(iris2,n=15)
  head(iris2,n=15)
}

FSA documentation built on Aug. 27, 2023, 1:06 a.m.

Related to headtail in FSA...