Generate structure of pre/post statistics
Source:R/renders.R
, R/filter_discrete.R
pre_post_stats.Rd
The method exported only for custom extensions use.
`.pre_post_stats` returns the statistics having html tags structure. `.pre_post_stats_text` returns the same output but flatten to a single character object. The latter function works faster and supports vector arguments.
Arguments
- current
Current step statistic value.
- previous
Previous step statistic value.
- name
Name displayed nearby the statistics output.
- brackets
If TRUE, statistics will be displayed in brackets.
- percent
Should current/previous ration in percentages be displayed?
- stats
Vector of "pre" and "post" defining which statistics should be returned. "pre" for previous, "post" for current and NULL for none.
Value
A `shiny.tag` class `span` object defining html structure of data/value statistics, or character object.
Examples
.pre_post_stats(5, 10, "books")
#> <span><span>books </span><span class="cb_delayed">5</span><span> / </span><span>10</span></span>
.pre_post_stats_text(5, 10, "books")
#> <span>books (<span class = 'cb_delayed'>5</span> / 10)</span>
.pre_post_stats(5, 10, "books", brackets = TRUE)
#> <span><span>books </span><span>(</span><span class="cb_delayed">5</span><span> / </span><span>10</span><span>)</span></span>
.pre_post_stats_text(5, 10, "books", brackets = TRUE)
#> <span>books (<span class = 'cb_delayed'>5</span> / 10)</span>
.pre_post_stats(5, 10, "books", percent = TRUE)
#> <span><span>books </span><span class="cb_delayed">5</span><span> / </span><span>10</span><span> (</span><span class="cb_delayed">50%</span><span>)</span></span>
.pre_post_stats_text(5, 10, "books", percent = TRUE)
#> <span>books (<span class = 'cb_delayed'>5</span> / 10) (<span class = 'cb_delayed'>50%</span>)</span>
.pre_post_stats_text(5:6, 10:11, "books", percent = TRUE)
#> <span>books (<span class = 'cb_delayed'>5</span> / 10) (<span class = 'cb_delayed'>50%</span>)</span>
#> <span>books (<span class = 'cb_delayed'>6</span> / 11) (<span class = 'cb_delayed'>55%</span>)</span>