|
27 | 27 | #' display the function name(s). If specified as a function (or functions) |
28 | 28 | #' then generic naming is used in the legend. |
29 | 29 | #' @param ... Currently unused. |
30 | | -#' |
| 30 | +#' @param discrete For `ppc_stat()` and `ppc_stat_grouped()`, if `TRUE` then a |
| 31 | +#' bar chart is used instead of a histogram. |
31 | 32 | #' @template details-binomial |
32 | 33 | #' @template return-ggplot-or-data |
33 | 34 | #' |
|
38 | 39 | #' @section Plot Descriptions: |
39 | 40 | #' \describe{ |
40 | 41 | #' \item{`ppc_stat()`, `ppc_stat_freqpoly()`}{ |
41 | | -#' A histogram or frequency polygon of the distribution of a statistic |
| 42 | +#' A histogram/bar plot or frequency polygon of the distribution of a statistic |
42 | 43 | #' computed by applying `stat` to each dataset (row) in `yrep`. The value of |
43 | 44 | #' the statistic in the observed data, `stat(y)`, is overlaid as a vertical |
44 | 45 | #' line. More details and example usage of `ppc_stat()` can be found in Gabry |
|
62 | 63 | #' ppc_stat(y, yrep, stat = "median") |
63 | 64 | #' ppc_stat(y, yrep, stat = "sd") + legend_none() |
64 | 65 | #' |
| 66 | +#' # discrete data example |
| 67 | +#' set.seed(0) |
| 68 | +#' y_discrete <- rbinom(20, 1, 0.2) |
| 69 | +#' yrep_discrete <- matrix(rbinom(2000, 1, prob = 0.4), 1000, 20, byrow = TRUE) |
| 70 | +#' ppc_stat(y_discrete, yrep_discrete, stat = "mean", discrete = TRUE) |
| 71 | +#' |
65 | 72 | #' # use your own function for the 'stat' argument |
66 | 73 | #' color_scheme_set("brightblue") |
67 | 74 | #' q25 <- function(y) quantile(y, 0.25) |
|
77 | 84 | #' ppc_stat_grouped(y, yrep, group, stat = "median") |
78 | 85 | #' ppc_stat_grouped(y, yrep, group, stat = "mad") + yaxis_text() |
79 | 86 | #' |
| 87 | +#' # discrete data example with groups |
| 88 | +#' group_discrete <- rep(c("First Half","Second Half"), each = 10) |
| 89 | +#' ppc_stat_grouped(y_discrete, yrep_discrete, group_discrete, stat = "mean", discrete = TRUE) |
| 90 | +#' |
80 | 91 | #' # force y-axes to have same scales, allow x axis to vary |
81 | 92 | #' ppc_stat_grouped(y, yrep, group, facet_args = list(scales = "free_x")) + yaxis_text() |
82 | 93 | #' |
|
0 commit comments