
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.
peek(x, n = 10, width = 10, ...)
A data.frame
object.
Number of rows to display.
The width of the columns to be displayed.
For internal use.
Prints a truncated head but invisibly returns x
.
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.
# NOT RUN {
(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)
# }
Run the code above in your browser using DataLab