peek at the results in a dplyr pipeline

peek(df, n = 5, message = NULL)

Arguments

df

dataframe in pipeline

n

number of rows to show

message

give a message along with peeking at the data

Details

A wrapper around giving a head and tail command but only as a side effect so the original data frame is passed along to continue on for furthermanipulation in the pipeline

Examples

library(dplyr) Theoph %>% select(Subject, Time, conc) %>% peek %>% group_by(Subject) %>% summarize(cmax = max(conc))
#> Taking a peek...
#> Subject Time conc #> 1 1 0.00 0.74 #> 2 1 0.25 2.84 #> 3 1 0.57 6.57 #> 4 1 1.12 10.50 #> 5 1 2.02 9.66
#> ...................
#> Subject Time conc #> 128 12 5.07 8.57 #> 129 12 7.07 6.59 #> 130 12 9.03 6.11 #> 131 12 12.05 4.57 #> 132 12 24.15 1.17
#> # A tibble: 12 x 2 #> Subject cmax #> <ord> <dbl> #> 1 6 6.44 #> 2 7 7.09 #> 3 8 7.56 #> 4 11 8 #> 5 3 8.2 #> 6 2 8.33 #> 7 4 8.6 #> 8 9 9.03 #> 9 12 9.75 #> 10 10 10.2 #> 11 1 10.5 #> 12 5 11.4
Theoph %>% select(Subject, Time, conc) %>% peek(message = "after select") %>% group_by(Subject) %>% summarize(cmax = max(conc))
#> after select
#> Subject Time conc #> 1 1 0.00 0.74 #> 2 1 0.25 2.84 #> 3 1 0.57 6.57 #> 4 1 1.12 10.50 #> 5 1 2.02 9.66
#> ...................
#> Subject Time conc #> 128 12 5.07 8.57 #> 129 12 7.07 6.59 #> 130 12 9.03 6.11 #> 131 12 12.05 4.57 #> 132 12 24.15 1.17
#> # A tibble: 12 x 2 #> Subject cmax #> <ord> <dbl> #> 1 6 6.44 #> 2 7 7.09 #> 3 8 7.56 #> 4 11 8 #> 5 3 8.2 #> 6 2 8.33 #> 7 4 8.6 #> 8 9 9.03 #> 9 12 9.75 #> 10 10 10.2 #> 11 1 10.5 #> 12 5 11.4
# nice for saving full objects but still seeing their output cmax_theoph <- Theoph %>% select(Subject, Time, conc) %>% peek(message = "after select") %>% group_by(Subject) %>% summarize(cmax = max(conc)) %>% peek
#> after select
#> Subject Time conc #> 1 1 0.00 0.74 #> 2 1 0.25 2.84 #> 3 1 0.57 6.57 #> 4 1 1.12 10.50 #> 5 1 2.02 9.66
#> ...................
#> Subject Time conc #> 128 12 5.07 8.57 #> 129 12 7.07 6.59 #> 130 12 9.03 6.11 #> 131 12 12.05 4.57 #> 132 12 24.15 1.17
#> Taking a peek...
#> # A tibble: 5 x 2 #> Subject cmax #> <ord> <dbl> #> 1 6 6.44 #> 2 7 7.09 #> 3 8 7.56 #> 4 11 8 #> 5 3 8.2
#> ...................
#> # A tibble: 5 x 2 #> Subject cmax #> <ord> <dbl> #> 1 9 9.03 #> 2 12 9.75 #> 3 10 10.2 #> 4 1 10.5 #> 5 5 11.4
cmax_theoph # still saves full output
#> # A tibble: 12 x 2 #> Subject cmax #> <ord> <dbl> #> 1 6 6.44 #> 2 7 7.09 #> 3 8 7.56 #> 4 11 8 #> 5 3 8.2 #> 6 2 8.33 #> 7 4 8.6 #> 8 9 9.03 #> 9 12 9.75 #> 10 10 10.2 #> 11 1 10.5 #> 12 5 11.4