Summarising a data set acts in the normal dplyr
manner to collapse groups
to individual rows. Any columns resulting from the summary can be added to
the history graph. In the history this also joins any stratified branches and
allows you to generate some summary statistics about the un-grouped data. See
dplyr::summarise()
.
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.
- ...
<
data-masking
> Name-value pairs of summary functions. The name will be the name of the variable in the result.The value can be:
A vector of length 1, e.g.
min(x)
,n()
, orsum(is.na(y))
.A data frame, to add multiple columns from a single expression.
Returning values with size 0 or >1 was deprecated as of 1.1.0. Please use
reframe()
for this instead. Named arguments passed on todplyr::reframe
.by
-
<
tidy-select
> Optionally, a selection of columns to group by for just this operation, functioning as an alternative togroup_by()
. For details and examples, see ?dplyr_by.
- .messages
a set of glue specs. The glue code can use any summary variable defined in the ... parameter, or any global variable, or {.strata}
- .headline
a headline glue spec. The glue code can use any summary variable defined in the ... parameter, or any global variable, or {.strata}
- .tag
if you want the summary data from this step in the future then give it a name with .tag.
Value
the .data dataframe summarised with the history graph updated showing the summarise operation as a new stage
Examples
library(dplyr)
library(dtrackr)
tmp = iris %>% group_by(Species) %>% track()
tmp %>% reframe(tibble(
param = c("mean","min","max"),
value = c(mean(Petal.Length), min(Petal.Length), max(Petal.Length))
), .messages="length {param}: {value}") %>% history()
#> dtrackr history:
#> number of flowchart steps: 2 (approx)
#> tags defined: <none>
#> items excluded so far: <not capturing exclusions>
#> last entry / entries:
#> ├ [Species:setosa]: "length mean: 1.462", "length min: 1", "length max: 1.9"
#> ├ [Species:versicolor]: "length mean: 4.26", "length min: 3", "length max: 5.1"
#> └ [Species:virginica]: "length mean: 5.552", "length min: 4.5", "length max: 6.9"