peek: Data Frame Viewing

Description Usage Arguments Details Value See Also Examples

Description

Convenience function to view all the columns of the head of a truncated data.frame. peek invisibly returns x. This makes its use ideal in a dplyr/magrittr pipeline.

Usage

1
peek(x, n = 10, width = 10, ...)

Arguments

x

A data.frame object.

n

Number of rows to display.

width

The width of the columns to be displayed.

...

For internal use.

Details

By default dplyr does not print all columns of a data frame (tbl_df). This makes inspection of data difficult at times, particularly with text string data. peek allows the user to see a truncated head for inspection purposes.

Value

Prints a truncated head but invisibly returns x.

See Also

head

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
(dat1 <- r_data_frame(100, id, sentence, paragraph))
peek(dat1)
peek(dat1, n = 20)
peek(dat1, width = 40)

library(dplyr)

## Use in a dplyr/magrittr pipeline to view the data (silly example)
par(mfrow = c(2, 2))

r_data_frame(1000, id, sex, pet, employment, eye, sentence, paragraph) %>%
    peek %>%
    (function(x, ind = 2:5){ invisible(lapply(ind, function(i) pie(table(x[[i]]))))})

## A wider data set example
dat2 <- r_data_theme()

dat2
peek(dat2)

trinker/wakefield documentation built on Sept. 17, 2020, 11:03 p.m.