Skip to content

Commit 68ba639

Browse files
committed
Use helper
1 parent 917dabd commit 68ba639

36 files changed

+246
-358
lines changed

R/geom-dotplot.r

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,17 @@
1717
#' to match the number of dots.
1818
#'
1919
#' @eval rd_aesthetics("geom", "dotplot")
20-
#' @section Computed variables:
21-
#' These are calculated by the 'stat' part of layers and can be accessed with
22-
#' [delayed evaluation][aes_eval].
23-
#' \describe{
24-
#' \item{`after_stat(x)`}{center of each bin, if binaxis is "x"}
25-
#' \item{`after_stat(y)`}{center of each bin, if binaxis is "x"}
26-
#' \item{`after_stat(binwidth)`}{max width of each bin if method is
27-
#' "dotdensity"; width of each bin if method is "histodot"}
28-
#' \item{`after_stat(count)`}{number of points in bin}
29-
#' \item{`after_stat(ncount)`}{count, scaled to maximum of 1}
30-
#' \item{`after_stat(density)`}{density of points in bin, scaled to integrate
31-
#' to 1, if method is "histodot"}
32-
#' \item{`after_stat(ndensity)`}{density, scaled to maximum of 1, if method is
33-
#' "histodot"}
34-
#' }
20+
#' @eval rd_computed_vars(
21+
#' x = 'center of each bin, if `binaxis` is `"x"`.',
22+
#' y = 'center of each bin, if `binaxis` is `"x"`.',
23+
#' binwidth = 'maximum width of each bin if method is `"dotdensity"`;
24+
#' width of each bin if method is `"histodot"`.',
25+
#' count = "number of points in bin.",
26+
#' ncount = "count, scaled to a maximum of 1.",
27+
#' density = 'density of points in bin, scaled to integrate to 1, if method
28+
#' is `"histodot"`.',
29+
#' ndensity = 'density, scaled to maximum of 1, if method is `"histodot"`.'
30+
#' )
3531
#'
3632
#' @inheritParams layer
3733
#' @inheritParams geom_point

R/stat-bin.r

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@
2727
#' or left edges of bins are included in the bin.
2828
#' @param pad If `TRUE`, adds empty bins at either end of x. This ensures
2929
#' frequency polygons touch 0. Defaults to `FALSE`.
30-
#' @section Computed variables:
31-
#' These are calculated by the 'stat' part of layers and can be accessed with
32-
#' [delayed evaluation][aes_eval].
33-
#' \describe{
34-
#' \item{`after_stat(count)`}{number of points in bin}
35-
#' \item{`after_stat(density)`}{density of points in bin, scaled to integrate
36-
#' to 1}
37-
#' \item{`after_stat(ncount)`}{count, scaled to maximum of 1}
38-
#' \item{`after_stat(ndensity)`}{density, scaled to maximum of 1}
39-
#' \item{`after_stat(width)`}{widths of bins}
40-
#' }
30+
#' @eval rd_computed_vars(
31+
#' count = "number of points in bin.",
32+
#' density = "density of points in bin, scaled to integrate to 1.",
33+
#' ncount = "count, scaled to a maximum of 1.",
34+
#' ndensity = "density, scaled to a maximum of 1.",
35+
#' width = "widths of bins."
36+
#' )
4137
#'
4238
#' @section Dropped variables:
4339
#' \describe{

R/stat-bin2d.r

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
#' @param drop if `TRUE` removes all cells with 0 counts.
66
#' @export
77
#' @rdname geom_bin_2d
8-
#' @section Computed variables:
9-
#' These are calculated by the 'stat' part of layers and can be accessed with
10-
#' [delayed evaluation][aes_eval].
11-
#' \describe{
12-
#' \item{`after_stat(count)`}{number of points in bin}
13-
#' \item{`after_stat(density)`}{density of points in bin, scaled to integrate
14-
#' to 1}
15-
#' \item{`after_stat(ncount)`}{count, scaled to maximum of 1}
16-
#' \item{`after_stat(ndensity)`}{density, scaled to maximum of 1}
17-
#' }
8+
#' @eval rd_computed_vars(
9+
#' count = "number of points in bin.",
10+
#' density = "density of points in bin, scaled to integrate to 1.",
11+
#' ncount = "count, scaled to maximum of 1.",
12+
#' ndensity = "density, scaled to a maximum of 1."
13+
#' )
1814
stat_bin_2d <- function(mapping = NULL, data = NULL,
1915
geom = "tile", position = "identity",
2016
...,

R/stat-binhex.r

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
#' @export
22
#' @rdname geom_hex
33
#' @inheritParams stat_bin_2d
4-
#' @section Computed variables:
5-
#' These are calculated by the 'stat' part of layers and can be accessed with
6-
#' [delayed evaluation][aes_eval].
7-
#' \describe{
8-
#' \item{`after_stat(count)`}{number of points in bin}
9-
#' \item{`after_stat(density)`}{density of points in bin, scaled to integrate
10-
#' to 1}
11-
#' \item{`after_stat(ncount)`}{count, scaled to maximum of 1}
12-
#' \item{`after_stat(ndensity)`}{density, scaled to maximum of 1}
13-
#' }
4+
#' @eval rd_computed_vars(
5+
#' count = "number of points in bin.",
6+
#' density = "density of points in bin, scaled to integrate to 1.",
7+
#' ncount = "count, scaled to maximum of 1.",
8+
#' ndensity = "density, scaled to maximum of 1."
9+
#' )
1410
stat_bin_hex <- function(mapping = NULL, data = NULL,
1511
geom = "hex", position = "identity",
1612
...,

R/stat-boxplot.r

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
#' @rdname geom_boxplot
22
#' @param coef Length of the whiskers as multiple of IQR. Defaults to 1.5.
33
#' @inheritParams stat_identity
4-
#' @section Computed variables:
5-
#' These are calculated by the 'stat' part of layers and can be accessed with
6-
#' [delayed evaluation][aes_eval]. `stat_boxplot()` provides the following
7-
#' variables, some of which depend on the orientation:
8-
#' \describe{
9-
#' \item{`after_stat(width)`}{width of boxplot}
10-
#' \item{`after_stat(ymin)` *or* `after_stat(xmin)`}{lower whisker = smallest
11-
#' observation greater than or equal to lower hinge - 1.5 * IQR}
12-
#' \item{`after_stat(lower)` *or* `after_stat(xlower)`}{lower hinge, 25%
13-
#' quantile}
14-
#' \item{`after_stat(notchlower)`}{lower edge of notch =
15-
#' median - 1.58 * IQR / sqrt(n)}
16-
#' \item{`after_stat(middle)` *or* `after_stat(xmiddle)`}{median,
17-
#' 50% quantile}
18-
#' \item{`after_stat(notchupper)`}{upper edge of notch =
19-
#' median + 1.58 * IQR / sqrt(n)}
20-
#' \item{`after_stat(upper)` *or* `after_stat(xupper)`}{upper hinge, 75%
21-
#' quantile}
22-
#' \item{`after_stat(ymax)` *or* `after_stat(xmax)`}{upper whisker = largest
23-
#' observation less than or equal to upper hinge + 1.5 * IQR}
24-
#' }
254
#' @export
5+
#' @eval rd_computed_vars(
6+
#' .details = "`stat_boxplot()` provides the following variables, some of
7+
#' which depend on the orientation:",
8+
#' width = "width of boxplot.",
9+
#' "ymin|xmin" = "lower whisker = smallest observation greater than or equal
10+
#' to lower hinger - 1.5 * IQR.",
11+
#' "lower|xlower" = "lower hinge, 25% quantile.",
12+
#' notchlower = "lower edge of notch = median - 1.58 * IQR / sqrt(n).",
13+
#' "middle|xmiddle" = "median, 50% quantile.",
14+
#' notchupper = "upper edge of notch = median + 1.58 * IQR / sqrt(n).",
15+
#' "upper|xupper" = "upper hinge, 75% quantile.",
16+
#' "ymax|xmax" = "upper whisker = largest observation less than or equal to
17+
#' upper hinger + 1.5 * IQR."
18+
#' )
2619
stat_boxplot <- function(mapping = NULL, data = NULL,
2720
geom = "boxplot", position = "dodge2",
2821
...,

R/stat-contour.r

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,21 @@
33
#' @export
44
#' @eval rd_aesthetics("stat", "contour")
55
#' @eval rd_aesthetics("stat", "contour_filled")
6-
#' @section Computed variables:
7-
#' These are calculated by the 'stat' part of layers and can be accessed with
8-
#' [delayed evaluation][aes_eval]. The computed variables differ somewhat for
9-
#' contour lines (computed by `stat_contour()`) and contour bands (filled
10-
#' contours, computed by `stat_contour_filled()`). The variables `nlevel` and
11-
#' `piece` are available for both, whereas `level_low`, `level_high`, and
12-
#' `level_mid` are only available for bands. The variable `level` is a numeric
13-
#' or a factor depending on whether lines or bands are calculated.
14-
#' \describe{
15-
#' \item{`after_stat(level)`}{Height of contour. For contour lines, this is
16-
#' numeric vector that represents bin boundaries. For contour bands, this is
17-
#' an ordered factor that represents bin ranges.}
18-
#' \item{`after_stat(level_low)`, `after_stat(level_high)`,
19-
#' `after_stat(level_mid)`}{(contour bands only) Lower and upper bin
20-
#' boundaries for each band, as well the mid point between the boundaries.}
21-
#' \item{`after_stat(nlevel)`}{Height of contour, scaled to maximum of 1.}
22-
#' \item{`after_stat(piece)`}{Contour piece (an integer).}
23-
#' }
6+
#' @eval rd_computed_vars(
7+
#' .details = "The computed variables differ somewhat for contour lines
8+
#' (compbuted by `stat_contour()`) and contour bands (filled contours,
9+
#' computed by `stat_contour_filled()`). The variables `nlevel` and `piece`
10+
#' are available for both, whereas `level_low`, `level_high`, and `level_mid`
11+
#' are only available for bands. The variable `level` is a numeric or a factor
12+
#' depending on whether lines or bands are calculated.",
13+
#' level = "Height of contour. For contour lines, this is a numeric vector
14+
#' that represents bin boundaries. For contour bands, this is an ordered
15+
#' factor that represents bin ranges.",
16+
#' "level_low,level_high,level_mid" = "(contour bands only) Lower and upper
17+
#' bin boundaries for each band, as well as the mid point between boundaries.",
18+
#' nlevel = "Height of contour, scaled to a maximum of 1.",
19+
#' piece = "Contour piece (an integer)."
20+
#' )
2421
#'
2522
#' @section Dropped variables:
2623
#' \describe{

R/stat-count.r

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
#' @section Computed variables:
2-
#' These are calculated by the 'stat' part of layers and can be accessed with
3-
#' [delayed evaluation][aes_eval].
4-
#' \describe{
5-
#' \item{`after_stat(count)`}{number of points in bin}
6-
#' \item{`after_stat(prop)`}{groupwise proportion}
7-
#' }
1+
#' @eval rd_computed_vars(
2+
#' count = "number of points in bin.",
3+
#' prop = "groupwise proportion"
4+
#' )
85
#' @seealso [stat_bin()], which bins data in ranges and counts the
96
#' cases in each range. It differs from `stat_count()`, which counts the
107
#' number of cases at each `x` position (without binning into ranges).

R/stat-density-2d.r

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@
1313
#' 'NULL'. This makes it possible to adjust the bandwidth while still
1414
#' using the a bandwidth estimator. For example, `adjust = 1/2` means
1515
#' use half of the default bandwidth.
16-
#' @section Computed variables:
17-
#' These are calculated by the 'stat' part of layers and can be accessed with
18-
#' [delayed evaluation][aes_eval]. `stat_density_2d()` and
19-
#' `stat_density_2d_filled()` compute different variables depending on whether
20-
#' contouring is turned on or off. With contouring off (`contour = FALSE`), both
21-
#' stats behave the same, and the following variables are provided:
22-
#' \describe{
23-
#' \item{`after_stat(density)`}{The density estimate.}
24-
#' \item{`after_stat(ndensity)`}{Density estimate, scaled to a maximum of 1.}
25-
#' \item{`after_stat(count)`}{Density estimate * number of observations in
26-
#' group.}
27-
#' \item{`after_stat(n)`}{Number of observations in each group.}
28-
#' }
16+
#' @eval rd_computed_vars(
17+
#' .details = "`stat_density_2d()` and `stat_density_2d_filled()` compute
18+
#' different variables depending on whether contouring is turned on or off.
19+
#' With contouring off (`contour = FALSE`), both stats behave the same, and
20+
#' the following variables are provided:",
21+
#' density = "The density estimate.",
22+
#' ndensity = "Density estimate, scaled to a maximum of 1.",
23+
#' count = "Density estimate * number of observations in group.",
24+
#' n = "Number of observations in each group."
25+
#' )
2926
#'
27+
#' @section Computed variables:
3028
#' With contouring on (`contour = TRUE`), either [stat_contour()] or
3129
#' [stat_contour_filled()] (for contour lines or contour bands,
3230
#' respectively) is run after the density estimate has been obtained,

R/stat-density.r

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,13 @@
2020
#' finite, boundary effect of default density estimation will be corrected by
2121
#' reflecting tails outside `bounds` around their closest edge. Data points
2222
#' outside of bounds are removed with a warning.
23-
#' @section Computed variables:
24-
#' These are calculated by the 'stat' part of layers and can be accessed with
25-
#' [delayed evaluation][aes_eval].
26-
#' \describe{
27-
#' \item{`after_stat(density)`}{density estimate}
28-
#' \item{`after_stat(count)`}{density * number of points - useful for stacked
29-
#' density plots}
30-
#' \item{`after_stat(scaled)`}{density estimate, scaled to maximum of 1}
31-
#' \item{`after_stat(n)`}{number of points}
32-
#' \item{`after_stat(ndensity)`}{alias for `scaled`, to mirror the syntax of
33-
#' [`stat_bin()`]}
34-
#' }
23+
#' @eval rd_computed_vars(
24+
#' density = "density estimate.",
25+
#' count = "density * number of points - useful for stacked density plots.",
26+
#' scaled = "density estimate, scaled to maximum of 1.",
27+
#' n = "number of points.",
28+
#' ndensity = "alias for `scaled`, to mirror the syntax of [`stat_bin()`]."
29+
#' )
3530
#' @export
3631
#' @rdname geom_density
3732
stat_density <- function(mapping = NULL, data = NULL,

R/stat-ecdf.r

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@
2020
#' of points to interpolate with.
2121
#' @param pad If `TRUE`, pad the ecdf with additional points (-Inf, 0)
2222
#' and (Inf, 1)
23-
#' @section Computed variables:
24-
#' These are calculated by the 'stat' part of layers and can be accessed with
25-
#' [delayed evaluation][aes_eval].
26-
#' \describe{
27-
#' \item{`after_stat(y)`}{cumulative density corresponding x}
28-
#' }
23+
#' @eval rd_computed_vars(
24+
#' y = "Cumulative density corresponding to `x`."
25+
#' )
2926
#' @export
3027
#' @examples
3128
#' set.seed(1)

0 commit comments

Comments
 (0)