p_slice_head {dtrackr} | R Documentation |
Slice operations
Description
Slice operations behave as in dplyr, except the history graph can be updated with
tracked dataframe with the before and after sizes of the dataframe.
See dplyr::slice()
, dplyr::slice_head()
, dplyr::slice_tail()
,
dplyr::slice_min()
, dplyr::slice_max()
, dplyr::slice_sample()
,
for more details on the underlying functions.
Usage
p_slice_head(
.data,
...,
.messages = c("{.count.in} before", "{.count.out} after"),
.headline = "slice data"
)
Arguments
.data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details. |
... |
Arguments passed on to
|
.messages |
a set of glue specs. The glue code can use any global variable, {.count.in}, {.count.out} for the input and output dataframes sizes respectively and {.excluded} for the difference |
.headline |
a glue spec. The glue code can use any global variable, {.count.in}, {.count.out} for the input and output dataframes sizes respectively. |
Value
the sliced dataframe with the history graph updated.
See Also
dplyr::slice_head()
Examples
library(dplyr)
library(dtrackr)
# the first 50% of the data frame, is taken and the history tracked
iris %>% track() %>% group_by(Species) %>%
slice_head(prop=0.5,.messages="{.count.out} / {.count.in}",
.headline="First {sprintf('%1.0f',prop*100)}%") %>%
history()
# The last 100 items:
iris %>% track() %>% group_by(Species) %>%
slice_tail(n=100,.messages="{.count.out} / {.count.in}",
.headline="Last 100") %>%
history()