peek: Peek into (show a subset of) a data frame or matrix.

View source: R/FSAUtils.R

peekR Documentation

Peek into (show a subset of) a data frame or matrix.

Description

Shows the first, last, and approximately evenly spaced rows from a data frame or matrix.

Usage

peek(x, n = 20L, which = NULL, addrownums = TRUE)

Arguments

x

A data frame or matrix.

n

A single numeric that indicates the number of rows to display.

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.

Value

A matrix or data.frame with 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

A. Powell Wheeler, powell.wheeler@gmail.com

See Also

headtail

Examples

peek(CutthroatAL)
peek(CutthroatAL,n=6)
peek(CutthroatAL,n=6,which=c("id","y1998","y1999","y2000"))

## Make a matrix for demonstration purposes only
mCutthroatAL <- as.matrix(CutthroatAL)
peek(mCutthroatAL)
peek(mCutthroatAL,n=6)
peek(mCutthroatAL,n=6,addrownums=FALSE)
peek(mCutthroatAL,n=6,which=2:4)

## Make a tibble type from dplyr ... note how peek() is not limited by
## the tibble restriction on number of rows to show (but head() is).
## Not run: 
  if (require(dplyr)) {
    CutthroatAL2 <- as_tibble(CutthroatAL)
    class(CutthroatAL2)
    peek(CutthroatAL2,n=6)
    head(CutthroatAL2,n=15)
  }

## End(Not run)


fishR-Core-Team/FSA documentation built on June 14, 2025, 10:01 p.m.