Any counts at the individual stages that was stored with a .tag option in a pipeline step can be recovered here. The idea here is to provide a quick way to access a single value for the counts or other details tagged in a pipeline into a format that can be reported in text of a document. (e.g. for a results section). For more examples the consort statement vignette has some examples of use.

p_tagged(.data, .tag = NULL, .strata = NULL, .glue = NULL, ...)

Arguments

.data

the tracked dataframe.

.tag

(optional) the tag to retrieve.

.strata

(optional) filter the tagged data by the strata. set to "" to filter just the top level ungrouped data.

.glue

(optional) a glue specification which will be applied to the tagged content to generate a .label for the tagged content.

...

(optional) any other named parameters will be passed to glue::glue and can be used to generate a label.

Value

various things depending on what is requested.

By default a tibble with a .tag column and all associated summary values in a nested .content column.

If a .strata column is specified the results are filtered to just those that match a given .strata grouping (i.e. this will be the grouping label on the flowchart). Ungrouped content will have an empty "" as .strata

If .tag is specified the result will be for a single tag and .content will be automatically un-nested to give a single un-nested dataframe of the content captured at the .tag tagged step. This could be single or multiple rows depending on whether the original data was grouped at the point of tagging.

If both the .tag and .glue is specified a .label column will be computed from .glue and the tagged content. If the result of this is a single row then just the string value of .label is returned.

If just the .glue is specified, an un-nested dataframe with .tag,.strata and .label columns with a label for each tag in each strata.

If this seems complex then the best thing is to experiment until you get the output you want, leaving any .glue options until you think you know what you are doing. It made sense at the time.

Examples

library(dplyr)
library(dtrackr)
tmp = iris %>% track() %>% comment(.tag = "step1")
tmp = tmp %>% filter(Species!="versicolor") %>% group_by(Species)
tmp %>% comment(.tag="step2") %>% tagged(.glue = "{.count}/{.total}")
#> # A tibble: 3 × 3
#>   .tag  .strata             .label 
#>   <chr> <chr>               <glue> 
#> 1 step1 ""                  150/150
#> 2 step2 "Species:setosa"    50/100 
#> 3 step2 "Species:virginica" 50/100