Group modifying a data set acts in the normal way. The internal mechanics of
the modify function are opaque to the history. This means these can be used
to wrap any unsupported operation without losing the history (e.g. df %>% track() %>% group_modify(function(d,...) { d %>% unsupported_operation() })
) Prior to the operation the size of the group is calculated {.count.in}
and after the operation the output size {.count.out} The group {.strata}
is also available (if grouped) for reporting See dplyr::group_modify()
.
p_group_modify(
.data,
...,
.messages = NULL,
.headline = .defaultHeadline(),
.type = "modify",
.tag = NULL
)
A grouped tibble
Arguments passed on to dplyr::group_modify
.f
A function or formula to apply to each group.
If a function, it is used as is. It should have at least 2 formal arguments.
If a formula, e.g. ~ head(.x)
, it is converted to a function.
In the formula, you can use
.
or .x
to refer to the subset of rows of .tbl
for the given group
.y
to refer to the key, a one row tibble with one column per grouping variable
that identifies the group
.keep
are the grouping variables kept in .x
a set of glue specs. The glue code can use any global variable, or {.strata},{.count.in},and {.count.out}
a headline glue spec. The glue code can use any global variable, or {.strata},{.count.in},and {.count.out}
default "modify": used to define formatting
if you want the summary data from this step in the future then give it a name with .tag.
the transformed .data dataframe with the history graph updated.
dplyr::group_modify()
library(dplyr)
library(dtrackr)
tmp = iris %>% track() %>% group_by(Species)
tmp %>% group_modify(
function(d,g,...) { return(tibble::tibble(x=runif(10))) },
.messages="{.count.in} in, {.count.out} out"
) %>% history()
#> dtrackr history:
#> number of flowchart steps: 3 (approx)
#> tags defined: <none>
#> items excluded so far: <not capturing exclusions>
#> last entry / entries:
#> ├ [Species:setosa]: "Species:setosa", "50 in, 10 out"
#> ├ [Species:versicolor]: "Species:versicolor", "50 in, 10 out"
#> └ [Species:virginica]: "Species:virginica", "50 in, 10 out"