Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chain stat #6326

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
explain procedure in details
teunbrand committed Feb 26, 2025
commit 495c7fa9d1adc21d1aa9c72bd918bdcbb1b3b350
15 changes: 15 additions & 0 deletions R/stat-chain.R
Original file line number Diff line number Diff line change
@@ -14,6 +14,21 @@
#' * The result of [`link_stat()`] to pass parameters or mapping instructions.
#'
#' @seealso [link_stat()]
#' @details
#' The procedure in which stats are chained are as follows. First, the
#' layer-level, undelayed aesthetics in the `mapping` argument are evaluated.
#' The data that results from that evaluation is passed to the first stat in
#' the `stats` argument to perform that stat's computation. If that first stat
#' is a [`link_stat`] with an `after.stat` component, the `after.stat` component
#' is evaluated before passing on the data to the next stat in the `stats`
#' argument. The next components in the `stats` argument work the same: the
#' data is passed on to compute the stat, then `after.stat` is evaluated. In
#' essence, the `after.stat` allows control over how computed variables are
#' passed to the next stat in the chain. Finally, once all components in the
#' `stats` arguments have been handled, the staged after stat components of
#' the layer-level `mapping` is evaluated. Per usual, the data are then handled
#' by the position and geom parts of a layer.
#'
#' @export
#'
#' @examples
@@ -89,8 +104,8 @@
params <- list2(...)
extra <- setdiff(names(params), stat$parameters(TRUE))
if (length(extra) > 0) {
cli::cli_warn("Ignoring unknown parameters: {.arg {extra}}.")
params <- params[setdiff(names(params), extra)]

Check warning on line 108 in R/stat-chain.R

Codecov / codecov/patch

R/stat-chain.R#L107-L108

Added lines #L107 - L108 were not covered by tests
}

structure(
15 changes: 15 additions & 0 deletions man/stat_chain.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.