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

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/FSAUtils.R

Description

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

Usage

1
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, derek@derekogle.com

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

See Also

headtail

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
peek(iris)
peek(iris,n=6)
peek(iris,n=6,which=c("Sepal.Length","Sepal.Width","Species"))
peek(iris,n=6,which=grep("Sepal",names(iris)))
peek(iris,n=200)

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

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

zanbi/FSA-Fisheries-Stock-Assessment- documentation built on Dec. 23, 2021, 9:12 p.m.