From 194b5faab467b834c6267a8547f751df5de89097 Mon Sep 17 00:00:00 2001 From: TJ Mahr Date: Mon, 2 Dec 2019 11:17:48 -0600 Subject: [PATCH 1/6] add the grouped overlay functions --- NAMESPACE | 2 + NEWS.md | 7 +- R/ppc-distributions.R | 187 ++++++++++++++++++++++++++++++------------ 3 files changed, 140 insertions(+), 56 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 2f5505cf..e6a099cd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -100,7 +100,9 @@ export(ppc_boxplot) export(ppc_data) export(ppc_dens) export(ppc_dens_overlay) +export(ppc_dens_overlay_grouped) export(ppc_ecdf_overlay) +export(ppc_ecdf_overlay_grouped) export(ppc_error_binned) export(ppc_error_hist) export(ppc_error_hist_grouped) diff --git a/NEWS.md b/NEWS.md index 1982868e..a7691221 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,13 +1,14 @@ - +* Added `ppc_dens_overlay_grouped()` and `ppc_ecdf_overlay_grouped()` for + plotting density and cumulative distributions of the posterior predictive + distribution (versus observed data) by group. # bayesplot 1.7.1 diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index 7f9a5ffd..c823ace8 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -33,7 +33,8 @@ #' `yrep` should therefore contain only a small number of rows. See the #' **Examples** section. #' } -#' \item{`ppc_dens_overlay(), ppc_ecdf_overlay()`}{ +#' \item{`ppc_ecdf_overlay(), ppc_dens_overlay(), +#' ppc_ecdf_overlay_grouped(), ppc_dens_overlay_grouped()`}{ #' Kernel density or empirical CDF estimates of each dataset (row) in #' `yrep` are overlaid, with the distribution of `y` itself on top #' (and in a darker shade). When using `ppc_ecdf_overlay()` with discrete @@ -58,6 +59,7 @@ #' yrep <- example_yrep_draws() #' dim(yrep) #' ppc_dens_overlay(y, yrep[1:25, ]) +#' #' \donttest{ #' # ppc_ecdf_overlay with continuous data (set discrete=TRUE if discrete data) #' ppc_ecdf_overlay(y, yrep[sample(nrow(yrep), 25), ]) @@ -85,6 +87,11 @@ #' ppc_freqpoly_grouped(y, yrep[1:3,], group, freq = FALSE) + yaxis_text() #' } #' +#' # density and distribution overlays by group +#' ppc_dens_overlay_grouped(y, yrep[1:25, ], group = group) +#' +#' ppc_ecdf_overlay_grouped(y, yrep[1:25, ], group = group) +#' #' # don't need to only use small number of rows for ppc_violin_grouped #' # (as it pools yrep draws within groups) #' color_scheme_set("gray") @@ -265,17 +272,21 @@ ppc_dens <- function(y, yrep, ..., trim = FALSE, size = 0.5, alpha = 1) { #' @rdname PPC-distributions #' @export #' @template args-density-controls -ppc_dens_overlay <- function(y, yrep, ..., - size = 0.25, - alpha = 0.7, - trim = FALSE, - bw = "nrd0", - adjust = 1, - kernel = "gaussian", - n_dens = 1024) { - +ppc_dens_overlay <- function( + y, + yrep, + ..., + group = NULL, + size = 0.25, + alpha = 0.7, + trim = FALSE, + bw = "nrd0", + adjust = 1, + kernel = "gaussian", + n_dens = 1024 +) { check_ignored_arguments(...) - data <- ppc_data(y, yrep) + data <- ppc_data(y, yrep, group = group) ggplot(data) + aes_(x = ~ value) + @@ -315,10 +326,41 @@ ppc_dens_overlay <- function(y, yrep, ..., yaxis_ticks(FALSE) } +#' @rdname PPC-distributions +#' @export +#' @template args-density-controls +ppc_dens_overlay_grouped <- function( + y, + yrep, + group, + ..., + size = 0.25, + alpha = 0.7, + trim = FALSE, + bw = "nrd0", + adjust = 1, + kernel = "gaussian", + n_dens = 1024 +) { + check_ignored_arguments(...) + p_overlay <- ppc_dens_overlay( + y = y, + yrep = yrep, + ..., + group = group, + size = size, + alpha = alpha, + trim = trim, + bw = bw, + adjust = adjust, + kernel = kernel, + n_dens = n_dens + ) - - + p_overlay + + facet_wrap("group") +} #' @export #' @rdname PPC-distributions @@ -327,48 +369,87 @@ ppc_dens_overlay <- function(y, yrep, ..., #' passed to [ggplot2::stat_ecdf()]. If `discrete` is set to #' `TRUE` then `geom="step"` is used. #' @param pad A logical scalar passed to [ggplot2::stat_ecdf()]. -ppc_ecdf_overlay <- - function(y, - yrep, - ..., - discrete = FALSE, - pad = TRUE, - size = 0.25, - alpha = 0.7) { - check_ignored_arguments(...) - data <- ppc_data(y, yrep) +ppc_ecdf_overlay <- function( + y, + yrep, + ..., + group = NULL, + discrete = FALSE, + pad = TRUE, + size = 0.25, + alpha = 0.7 +) { + check_ignored_arguments(...) + data <- ppc_data(y, yrep, group = group) - ggplot(data) + - aes_(x = ~ value) + - hline_at( - c(0, 0.5, 1), - size = c(0.2, 0.1, 0.2), - linetype = 2, - color = get_color("dh") - ) + - stat_ecdf( - data = function(x) dplyr::filter(x, !.data$is_y), - mapping = aes_(group = ~ rep_id, color = "yrep"), - geom = if (discrete) "step" else "line", - size = size, - alpha = alpha, - pad = pad - ) + - stat_ecdf( - data = function(x) dplyr::filter(x, .data$is_y), - mapping = aes_(color = "y"), - geom = if (discrete) "step" else "line", - size = 1, - pad = pad - ) + - scale_color_ppc_dist() + - xlab(y_label()) + - scale_y_continuous(breaks = c(0, 0.5, 1)) + - yaxis_title(FALSE) + - xaxis_title(FALSE) + - yaxis_ticks(FALSE) + + ggplot(data) + + aes_(x = ~ value) + + hline_at( + 0.5, + size = 0.1, + linetype = 2, + color = get_color("dh") + ) + + hline_at( + c(0, 1), + size = 0.2, + linetype = 2, + color = get_color("dh") + ) + + stat_ecdf( + data = function(x) dplyr::filter(x, !.data$is_y), + mapping = aes_(group = ~ rep_id, color = "yrep"), + geom = if (discrete) "step" else "line", + size = size, + alpha = alpha, + pad = pad + ) + + stat_ecdf( + data = function(x) dplyr::filter(x, .data$is_y), + mapping = aes_(color = "y"), + geom = if (discrete) "step" else "line", + size = 1, + pad = pad + ) + + scale_color_ppc_dist() + + xlab(y_label()) + + scale_y_continuous(breaks = c(0, 0.5, 1)) + + yaxis_title(FALSE) + + xaxis_title(FALSE) + + yaxis_ticks(FALSE) + bayesplot_theme_get() - } +} + +#' @export +#' @rdname PPC-distributions +ppc_ecdf_overlay_grouped <- function( + y, + yrep, + group, + ..., + discrete = FALSE, + pad = TRUE, + size = 0.25, + alpha = 0.7 +) { + check_ignored_arguments(...) + + p_overlay <- ppc_ecdf_overlay( + y = y, + yrep = yrep, + group = group, + ..., + discrete = discrete, + pad = pad, + size = size, + alpha = alpha + ) + + p_overlay + + facet_wrap("group") +} + + #' @export #' @rdname PPC-distributions From 5ce91d7286fc7e3a50931ac03592ad3bfed7e646 Mon Sep 17 00:00:00 2001 From: TJ Mahr Date: Mon, 2 Dec 2019 11:33:15 -0600 Subject: [PATCH 2/6] force axis lines --- R/ppc-distributions.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index c823ace8..f6b72f35 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -359,7 +359,8 @@ ppc_dens_overlay_grouped <- function( ) p_overlay + - facet_wrap("group") + facet_wrap("group") + + force_axes_in_facets() } #' @export @@ -446,7 +447,8 @@ ppc_ecdf_overlay_grouped <- function( ) p_overlay + - facet_wrap("group") + facet_wrap("group") + + force_axes_in_facets() } From a0fb12360708fd9a4c705bc25ec1b037a50bea78 Mon Sep 17 00:00:00 2001 From: TJ Mahr Date: Mon, 2 Dec 2019 11:54:49 -0600 Subject: [PATCH 3/6] set `vjust` in `color_scheme_view()`. close #213 --- R/bayesplot-colors.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/bayesplot-colors.R b/R/bayesplot-colors.R index 31f76228..de06df9e 100644 --- a/R/bayesplot-colors.R +++ b/R/bayesplot-colors.R @@ -230,8 +230,9 @@ plot_scheme <- function(scheme = NULL) { legend_none() + xaxis_text( face = "bold", - margin = margin(t = -3, b = 10), + margin = margin(t = -3, b = 10, unit = "pt"), angle = 0, + vjust = 1, debug = FALSE ) } From b9c0235073b3e0b170b6a174f4e4e395d00c39cd Mon Sep 17 00:00:00 2001 From: TJ Mahr Date: Mon, 2 Dec 2019 12:02:14 -0600 Subject: [PATCH 4/6] add unit tests for ppc_*_overlay_grouped() functions --- NEWS.md | 4 +- tests/figs/deps.txt | 2 +- .../mcmc-areas-ridges-default.svg | 5 + .../mcmc-areas-ridges-inner.svg | 5 + .../mcmc-areas-ridges-outer.svg | 5 + .../ppc-dens-overlay-grouped-alpha-size.svg | 237 ++++++++++++++++++ .../ppc-dens-overlay-grouped-default.svg | 237 ++++++++++++++++++ .../ppc-ecdf-overlay-default.svg | 2 +- .../ppc-ecdf-overlay-discrete-size-alpha.svg | 2 +- .../ppc-ecdf-overlay-grouped-default.svg | 132 ++++++++++ ...df-overlay-grouped-discrete-size-alpha.svg | 132 ++++++++++ .../ppc-violin-grouped-default.svg | 71 ++++++ .../ppc-violin-grouped-points-low-jitter.svg | 167 ++++++++++++ .../ppc-violin-grouped-with-points.svg | 171 +++++++++++++ tests/testthat/test-ppc-distributions.R | 50 +++- 15 files changed, 1216 insertions(+), 6 deletions(-) create mode 100644 tests/figs/ppc-distributions/ppc-dens-overlay-grouped-alpha-size.svg create mode 100644 tests/figs/ppc-distributions/ppc-dens-overlay-grouped-default.svg create mode 100644 tests/figs/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg create mode 100644 tests/figs/ppc-distributions/ppc-ecdf-overlay-grouped-discrete-size-alpha.svg create mode 100644 tests/figs/ppc-distributions/ppc-violin-grouped-default.svg create mode 100644 tests/figs/ppc-distributions/ppc-violin-grouped-points-low-jitter.svg create mode 100644 tests/figs/ppc-distributions/ppc-violin-grouped-with-points.svg diff --git a/NEWS.md b/NEWS.md index a7691221..56d92659 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,7 +8,9 @@ * Added `ppc_dens_overlay_grouped()` and `ppc_ecdf_overlay_grouped()` for plotting density and cumulative distributions of the posterior predictive - distribution (versus observed data) by group. + distribution (versus observed data) by group. (#212) + +* Fix bug in `color_scheme_view()` minimal theme (#213). # bayesplot 1.7.1 diff --git a/tests/figs/deps.txt b/tests/figs/deps.txt index 059d3572..0f64e23e 100644 --- a/tests/figs/deps.txt +++ b/tests/figs/deps.txt @@ -1,3 +1,3 @@ - vdiffr-svg-engine: 1.0 -- vdiffr: 0.3.0 +- vdiffr: 0.3.1 - freetypeharfbuzz: 0.2.5 diff --git a/tests/figs/mcmc-intervals/mcmc-areas-ridges-default.svg b/tests/figs/mcmc-intervals/mcmc-areas-ridges-default.svg index f624b15d..d90de624 100644 --- a/tests/figs/mcmc-intervals/mcmc-areas-ridges-default.svg +++ b/tests/figs/mcmc-intervals/mcmc-areas-ridges-default.svg @@ -17,6 +17,11 @@ + + + + + diff --git a/tests/figs/mcmc-intervals/mcmc-areas-ridges-inner.svg b/tests/figs/mcmc-intervals/mcmc-areas-ridges-inner.svg index 6fc6d7b7..3c9a3a42 100644 --- a/tests/figs/mcmc-intervals/mcmc-areas-ridges-inner.svg +++ b/tests/figs/mcmc-intervals/mcmc-areas-ridges-inner.svg @@ -17,6 +17,11 @@ + + + + + diff --git a/tests/figs/mcmc-intervals/mcmc-areas-ridges-outer.svg b/tests/figs/mcmc-intervals/mcmc-areas-ridges-outer.svg index 967a8fd8..fd1f817d 100644 --- a/tests/figs/mcmc-intervals/mcmc-areas-ridges-outer.svg +++ b/tests/figs/mcmc-intervals/mcmc-areas-ridges-outer.svg @@ -17,6 +17,11 @@ + + + + + diff --git a/tests/figs/ppc-distributions/ppc-dens-overlay-grouped-alpha-size.svg b/tests/figs/ppc-distributions/ppc-dens-overlay-grouped-alpha-size.svg new file mode 100644 index 00000000..dd90e502 --- /dev/null +++ b/tests/figs/ppc-distributions/ppc-dens-overlay-grouped-alpha-size.svg @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +C + + + + + + + + + + +D + + + + + + + + + + +A + + + + + + + + + + +B + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + + + +y +y +r +e +p +ppc_dens_overlay_grouped (alpha, size) + diff --git a/tests/figs/ppc-distributions/ppc-dens-overlay-grouped-default.svg b/tests/figs/ppc-distributions/ppc-dens-overlay-grouped-default.svg new file mode 100644 index 00000000..5b2b6180 --- /dev/null +++ b/tests/figs/ppc-distributions/ppc-dens-overlay-grouped-default.svg @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +C + + + + + + + + + + +D + + + + + + + + + + +A + + + + + + + + + + +B + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + + + +y +y +r +e +p +ppc_dens_overlay_grouped (default) + diff --git a/tests/figs/ppc-distributions/ppc-ecdf-overlay-default.svg b/tests/figs/ppc-distributions/ppc-ecdf-overlay-default.svg index 0975d0c2..90a9d067 100644 --- a/tests/figs/ppc-distributions/ppc-ecdf-overlay-default.svg +++ b/tests/figs/ppc-distributions/ppc-ecdf-overlay-default.svg @@ -17,8 +17,8 @@ - + diff --git a/tests/figs/ppc-distributions/ppc-ecdf-overlay-discrete-size-alpha.svg b/tests/figs/ppc-distributions/ppc-ecdf-overlay-discrete-size-alpha.svg index 8b5e4afb..352dae40 100644 --- a/tests/figs/ppc-distributions/ppc-ecdf-overlay-discrete-size-alpha.svg +++ b/tests/figs/ppc-distributions/ppc-ecdf-overlay-discrete-size-alpha.svg @@ -17,8 +17,8 @@ - + diff --git a/tests/figs/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg b/tests/figs/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg new file mode 100644 index 00000000..a9401a66 --- /dev/null +++ b/tests/figs/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1 + + + + + + + + + + +2 + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 + + + + + + + +0 +1 +2 +3 +4 +5 + +0.0 +0.5 +1.0 + + + + + + + +y +y +r +e +p +ppc_ecdf_overlay_grouped (default) + diff --git a/tests/figs/ppc-distributions/ppc-ecdf-overlay-grouped-discrete-size-alpha.svg b/tests/figs/ppc-distributions/ppc-ecdf-overlay-grouped-discrete-size-alpha.svg new file mode 100644 index 00000000..74d5a838 --- /dev/null +++ b/tests/figs/ppc-distributions/ppc-ecdf-overlay-grouped-discrete-size-alpha.svg @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1 + + + + + + + + + + +2 + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 + + + + + + + +0 +1 +2 +3 +4 +5 + +0.0 +0.5 +1.0 + + + + + + + +y +y +r +e +p +ppc_ecdf_overlay_grouped (discrete, size, alpha) + diff --git a/tests/figs/ppc-distributions/ppc-violin-grouped-default.svg b/tests/figs/ppc-distributions/ppc-violin-grouped-default.svg new file mode 100644 index 00000000..a6c439d9 --- /dev/null +++ b/tests/figs/ppc-distributions/ppc-violin-grouped-default.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 +4 + + + + + + + + + +A +B +C +D + + +y +y +r +e +p +ppc_violin_grouped (default) + diff --git a/tests/figs/ppc-distributions/ppc-violin-grouped-points-low-jitter.svg b/tests/figs/ppc-distributions/ppc-violin-grouped-points-low-jitter.svg new file mode 100644 index 00000000..062c5dcf --- /dev/null +++ b/tests/figs/ppc-distributions/ppc-violin-grouped-points-low-jitter.svg @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 +4 + + + + + + + + + +A +B +C +D + + +y +y +r +e +p +ppc_violin_grouped (points, low jitter) + diff --git a/tests/figs/ppc-distributions/ppc-violin-grouped-with-points.svg b/tests/figs/ppc-distributions/ppc-violin-grouped-with-points.svg new file mode 100644 index 00000000..6be9b690 --- /dev/null +++ b/tests/figs/ppc-distributions/ppc-violin-grouped-with-points.svg @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 +4 + + + + + + + + + +A +B +C +D + + +y +y +r +e +p +ppc_violin_grouped (with points) + diff --git a/tests/testthat/test-ppc-distributions.R b/tests/testthat/test-ppc-distributions.R index e9e20c9b..cc43a035 100644 --- a/tests/testthat/test-ppc-distributions.R +++ b/tests/testthat/test-ppc-distributions.R @@ -118,8 +118,34 @@ test_that("ppc_ecdf_overlay renders correctly", { vdiff_yrep2, discrete = TRUE, size = 2, - alpha = .2) - vdiffr::expect_doppelganger("ppc_ecdf_overlay (discrete, size, alpha)", p_custom) + alpha = .2 + ) + + vdiffr::expect_doppelganger( + "ppc_ecdf_overlay (discrete, size, alpha)", + p_custom + ) +}) + +test_that("ppc_ecdf_overlay_grouped renders correctly", { + testthat::skip_on_cran() + + p_base <- ppc_ecdf_overlay_grouped(vdiff_y2, vdiff_yrep2, vdiff_group2) + vdiffr::expect_doppelganger("ppc_ecdf_overlay_grouped (default)", p_base) + + p_custom <- ppc_ecdf_overlay_grouped( + vdiff_y2, + vdiff_yrep2, + vdiff_group2, + discrete = TRUE, + size = 2, + alpha = .2 + ) + + vdiffr::expect_doppelganger( + "ppc_ecdf_overlay_grouped (discrete, size, alpha)", + p_custom + ) }) test_that("ppc_dens renders correctly", { @@ -139,6 +165,26 @@ test_that("ppc_dens_overlay renders correctly", { vdiffr::expect_doppelganger("ppc_dens_overlay (alpha, size)", p_custom) }) +test_that("ppc_dens_overlay_grouped renders correctly", { + testthat::skip_on_cran() + + p_base <- ppc_dens_overlay_grouped(vdiff_y, vdiff_yrep, vdiff_group) + vdiffr::expect_doppelganger("ppc_dens_overlay_grouped (default)", p_base) + + p_custom <- ppc_dens_overlay_grouped( + vdiff_y, + vdiff_yrep, + vdiff_group, + size = 1, + alpha = 0.2 + ) + + vdiffr::expect_doppelganger( + "ppc_dens_overlay_grouped (alpha, size)", + p_custom + ) +}) + test_that("ppc_violin_grouped renders correctly", { testthat::skip_on_cran() testthat::skip_if_not(getRversion() >= "3.6.0") From ae0c66d8329e3c7f7450d6942fb79ebacb43ca1c Mon Sep 17 00:00:00 2001 From: TJ Mahr Date: Thu, 3 Dec 2020 14:07:46 -0600 Subject: [PATCH 5/6] remove `group` arg from `ppc_dens_overlay()` --- DESCRIPTION | 2 +- R/ppc-distributions.R | 17 +++++++++++------ man/MCMC-diagnostics.Rd | 4 ++-- man/MCMC-distributions.Rd | 2 +- man/MCMC-intervals.Rd | 2 +- man/MCMC-parcoord.Rd | 6 +++--- man/MCMC-scatterplots.Rd | 2 +- man/MCMC-traces.Rd | 3 ++- man/PPC-discrete.Rd | 4 ++-- man/PPC-distributions.Rd | 35 ++++++++++++++++++++++++++++++++++- man/PPC-intervals.Rd | 2 +- man/PPC-loo.Rd | 4 ++-- man/bayesplot-colors.Rd | 2 +- man/bayesplot-extractors.Rd | 2 +- man/bayesplot-helpers.Rd | 22 +++++++++++----------- man/bayesplot_theme_get.Rd | 8 ++++---- man/theme_default.Rd | 2 +- man/tidy-params.Rd | 10 +++++----- 18 files changed, 84 insertions(+), 45 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3260237c..1b7edaf8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -49,7 +49,7 @@ Suggests: shinystan (>= 2.3.0), testthat (>= 2.0.0), vdiffr -RoxygenNote: 7.1.0 +RoxygenNote: 7.1.1 VignetteBuilder: knitr Encoding: UTF-8 Roxygen: list(markdown = TRUE) diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index f6b72f35..0cc24c7d 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -276,7 +276,6 @@ ppc_dens_overlay <- function( y, yrep, ..., - group = NULL, size = 0.25, alpha = 0.7, trim = FALSE, @@ -286,7 +285,7 @@ ppc_dens_overlay <- function( n_dens = 1024 ) { check_ignored_arguments(...) - data <- ppc_data(y, yrep, group = group) + data <- ppc_data(y, yrep) ggplot(data) + aes_(x = ~ value) + @@ -348,7 +347,6 @@ ppc_dens_overlay_grouped <- function( y = y, yrep = yrep, ..., - group = group, size = size, alpha = alpha, trim = trim, @@ -357,6 +355,11 @@ ppc_dens_overlay_grouped <- function( kernel = kernel, n_dens = n_dens ) + # Use + list(data) trick to replace the data in the plot. The layer-specific + # data in the y and yrep layers should be safe because they are + # specified using a function on the main plot data. + data <- ppc_data(y, yrep, group = group) + p_overlay <- p_overlay + list(data) p_overlay + facet_wrap("group") + @@ -374,14 +377,13 @@ ppc_ecdf_overlay <- function( y, yrep, ..., - group = NULL, discrete = FALSE, pad = TRUE, size = 0.25, alpha = 0.7 ) { check_ignored_arguments(...) - data <- ppc_data(y, yrep, group = group) + data <- ppc_data(y, yrep) ggplot(data) + aes_(x = ~ value) + @@ -438,7 +440,6 @@ ppc_ecdf_overlay_grouped <- function( p_overlay <- ppc_ecdf_overlay( y = y, yrep = yrep, - group = group, ..., discrete = discrete, pad = pad, @@ -446,6 +447,10 @@ ppc_ecdf_overlay_grouped <- function( alpha = alpha ) + # Use + list(data) trick to replace the data in the plot + data <- ppc_data(y, yrep, group = group) + p_overlay <- p_overlay + list(data) + p_overlay + facet_wrap("group") + force_axes_in_facets() diff --git a/man/MCMC-diagnostics.Rd b/man/MCMC-diagnostics.Rd index 1dcc196f..9bc4f7ae 100644 --- a/man/MCMC-diagnostics.Rd +++ b/man/MCMC-diagnostics.Rd @@ -50,7 +50,7 @@ mcmc_acf_bar( \item{size}{An optional value to override \code{\link[ggplot2:geom_point]{ggplot2::geom_point()}}'s default size (for \code{mcmc_rhat()}, \code{mcmc_neff()}) or -\code{\link[ggplot2:geom_line]{ggplot2::geom_line()}}'s default size (for \code{mcmc_acf()}).} +\code{\link[ggplot2:geom_path]{ggplot2::geom_line()}}'s default size (for \code{mcmc_acf()}).} \item{binwidth}{Passed to \code{\link[ggplot2:geom_histogram]{ggplot2::geom_histogram()}} to override the default binwidth.} @@ -78,7 +78,7 @@ similar functions. Examples of using \code{pars} in this way can be found on the \item{regex_pars}{An optional \link[base:grep]{regular expression} to use for parameter selection. Can be specified instead of \code{pars} or in addition to \code{pars}. When using \code{pars} for tidy parameter selection, the \code{regex_pars} -argument is ignored since \link[tidyselect:select_helpers]{select helpers} +argument is ignored since \link[tidyselect:language]{select helpers} perform a similar function.} \item{facet_args}{A named list of arguments (other than \code{facets}) passed diff --git a/man/MCMC-distributions.Rd b/man/MCMC-distributions.Rd index 93f28aa4..70385b96 100644 --- a/man/MCMC-distributions.Rd +++ b/man/MCMC-distributions.Rd @@ -108,7 +108,7 @@ similar functions. Examples of using \code{pars} in this way can be found on the \item{regex_pars}{An optional \link[base:grep]{regular expression} to use for parameter selection. Can be specified instead of \code{pars} or in addition to \code{pars}. When using \code{pars} for tidy parameter selection, the \code{regex_pars} -argument is ignored since \link[tidyselect:select_helpers]{select helpers} +argument is ignored since \link[tidyselect:language]{select helpers} perform a similar function.} \item{transformations}{Optionally, transformations to apply to parameters diff --git a/man/MCMC-intervals.Rd b/man/MCMC-intervals.Rd index 73b7b178..0c057c97 100644 --- a/man/MCMC-intervals.Rd +++ b/man/MCMC-intervals.Rd @@ -113,7 +113,7 @@ similar functions. Examples of using \code{pars} in this way can be found on the \item{regex_pars}{An optional \link[base:grep]{regular expression} to use for parameter selection. Can be specified instead of \code{pars} or in addition to \code{pars}. When using \code{pars} for tidy parameter selection, the \code{regex_pars} -argument is ignored since \link[tidyselect:select_helpers]{select helpers} +argument is ignored since \link[tidyselect:language]{select helpers} perform a similar function.} \item{transformations}{Optionally, transformations to apply to parameters diff --git a/man/MCMC-parcoord.Rd b/man/MCMC-parcoord.Rd index 945cfc13..1f169343 100644 --- a/man/MCMC-parcoord.Rd +++ b/man/MCMC-parcoord.Rd @@ -47,7 +47,7 @@ similar functions. Examples of using \code{pars} in this way can be found on the \item{regex_pars}{An optional \link[base:grep]{regular expression} to use for parameter selection. Can be specified instead of \code{pars} or in addition to \code{pars}. When using \code{pars} for tidy parameter selection, the \code{regex_pars} -argument is ignored since \link[tidyselect:select_helpers]{select helpers} +argument is ignored since \link[tidyselect:language]{select helpers} perform a similar function.} \item{transformations}{Optionally, transformations to apply to parameters @@ -74,7 +74,7 @@ abbreviated for convenience in interactive use (e.g., \code{transform}).} \item{...}{Currently ignored.} -\item{size, alpha}{Arguments passed on to \code{\link[ggplot2:geom_line]{ggplot2::geom_line()}}.} +\item{size, alpha}{Arguments passed on to \code{\link[ggplot2:geom_path]{ggplot2::geom_line()}}.} \item{np}{For models fit using \link{NUTS} (more generally, any \href{https://en.wikipedia.org/wiki/Symplectic_integrator}{symplectic integrator}), @@ -89,7 +89,7 @@ argument is specified.} \item{div_color, div_size, div_alpha}{Optional arguments to the \code{parcoord_style_np()} helper function that are eventually passed to -\code{\link[ggplot2:geom_line]{ggplot2::geom_line()}} if the \code{np} argument is also specified. They control +\code{\link[ggplot2:geom_path]{ggplot2::geom_line()}} if the \code{np} argument is also specified. They control the color, size, and transparency specifications for showing divergences in the plot. The default values are displayed in the \strong{Usage} section above.} } diff --git a/man/MCMC-scatterplots.Rd b/man/MCMC-scatterplots.Rd index ab1df0be..546af2f4 100644 --- a/man/MCMC-scatterplots.Rd +++ b/man/MCMC-scatterplots.Rd @@ -88,7 +88,7 @@ similar functions. Examples of using \code{pars} in this way can be found on the \item{regex_pars}{An optional \link[base:grep]{regular expression} to use for parameter selection. Can be specified instead of \code{pars} or in addition to \code{pars}. When using \code{pars} for tidy parameter selection, the \code{regex_pars} -argument is ignored since \link[tidyselect:select_helpers]{select helpers} +argument is ignored since \link[tidyselect:language]{select helpers} perform a similar function.} \item{transformations}{Optionally, transformations to apply to parameters diff --git a/man/MCMC-traces.Rd b/man/MCMC-traces.Rd index d89cc43c..9c12838c 100644 --- a/man/MCMC-traces.Rd +++ b/man/MCMC-traces.Rd @@ -47,6 +47,7 @@ mcmc_rank_overlay( pars = character(), regex_pars = character(), transformations = list(), + facet_args = list(), ..., n_bins = 20, ref_line = FALSE @@ -92,7 +93,7 @@ similar functions. Examples of using \code{pars} in this way can be found on the \item{regex_pars}{An optional \link[base:grep]{regular expression} to use for parameter selection. Can be specified instead of \code{pars} or in addition to \code{pars}. When using \code{pars} for tidy parameter selection, the \code{regex_pars} -argument is ignored since \link[tidyselect:select_helpers]{select helpers} +argument is ignored since \link[tidyselect:language]{select helpers} perform a similar function.} \item{transformations}{Optionally, transformations to apply to parameters diff --git a/man/PPC-discrete.Rd b/man/PPC-discrete.Rd index 61854d64..d3df4b62 100644 --- a/man/PPC-discrete.Rd +++ b/man/PPC-discrete.Rd @@ -61,9 +61,9 @@ of the expected counts.} \code{\link[ggplot2:geom_bar]{ggplot2::geom_bar()}} to control the bar width.} \item{size, fatten}{For \code{ppc_bars()} and \code{ppc_bars_grouped()}, \code{size} and -\code{fatten} are passed to \code{\link[ggplot2:geom_pointrange]{ggplot2::geom_pointrange()}} to control the +\code{fatten} are passed to \code{\link[ggplot2:geom_linerange]{ggplot2::geom_pointrange()}} to control the appearance of the \code{yrep} points and intervals. For \code{ppc_rootogram()} \code{size} -is passed to \code{\link[ggplot2:geom_line]{ggplot2::geom_line()}}.} +is passed to \code{\link[ggplot2:geom_path]{ggplot2::geom_line()}}.} \item{freq}{For \code{ppc_bars()} and \code{ppc_bars_grouped()}, if \code{TRUE} (the default) the y-axis will display counts. Setting \code{freq=FALSE} will put diff --git a/man/PPC-distributions.Rd b/man/PPC-distributions.Rd index 525999c6..b5c0c00f 100644 --- a/man/PPC-distributions.Rd +++ b/man/PPC-distributions.Rd @@ -9,7 +9,9 @@ \alias{ppc_freqpoly_grouped} \alias{ppc_dens} \alias{ppc_dens_overlay} +\alias{ppc_dens_overlay_grouped} \alias{ppc_ecdf_overlay} +\alias{ppc_ecdf_overlay_grouped} \alias{ppc_violin_grouped} \title{PPC distributions} \usage{ @@ -55,6 +57,20 @@ ppc_dens_overlay( n_dens = 1024 ) +ppc_dens_overlay_grouped( + y, + yrep, + group, + ..., + size = 0.25, + alpha = 0.7, + trim = FALSE, + bw = "nrd0", + adjust = 1, + kernel = "gaussian", + n_dens = 1024 +) + ppc_ecdf_overlay( y, yrep, @@ -65,6 +81,17 @@ ppc_ecdf_overlay( alpha = 0.7 ) +ppc_ecdf_overlay_grouped( + y, + yrep, + group, + ..., + discrete = FALSE, + pad = TRUE, + size = 0.25, + alpha = 0.7 +) + ppc_violin_grouped( y, yrep, @@ -171,7 +198,7 @@ variable for \code{y} and each dataset (row) in \code{yrep}. For this plot \code{yrep} should therefore contain only a small number of rows. See the \strong{Examples} section. } -\item{\verb{ppc_dens_overlay(), ppc_ecdf_overlay()}}{ +\item{\verb{ppc_ecdf_overlay(), ppc_dens_overlay(), ppc_ecdf_overlay_grouped(), ppc_dens_overlay_grouped()}}{ Kernel density or empirical CDF estimates of each dataset (row) in \code{yrep} are overlaid, with the distribution of \code{y} itself on top (and in a darker shade). When using \code{ppc_ecdf_overlay()} with discrete @@ -193,6 +220,7 @@ y <- example_y_data() yrep <- example_yrep_draws() dim(yrep) ppc_dens_overlay(y, yrep[1:25, ]) + \donttest{ # ppc_ecdf_overlay with continuous data (set discrete=TRUE if discrete data) ppc_ecdf_overlay(y, yrep[sample(nrow(yrep), 25), ]) @@ -220,6 +248,11 @@ ppc_freqpoly_grouped(y, yrep[1:3,], group) + yaxis_text() ppc_freqpoly_grouped(y, yrep[1:3,], group, freq = FALSE) + yaxis_text() } +# density and distribution overlays by group +ppc_dens_overlay_grouped(y, yrep[1:25, ], group = group) + +ppc_ecdf_overlay_grouped(y, yrep[1:25, ], group = group) + # don't need to only use small number of rows for ppc_violin_grouped # (as it pools yrep draws within groups) color_scheme_set("gray") diff --git a/man/PPC-intervals.Rd b/man/PPC-intervals.Rd index 579ce68f..9e8b6cd9 100644 --- a/man/PPC-intervals.Rd +++ b/man/PPC-intervals.Rd @@ -108,7 +108,7 @@ passed to \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}} to control fac \item{alpha, size, fatten}{Arguments passed to geoms. For ribbon plots \code{alpha} and \code{size} are passed to \code{\link[ggplot2:geom_ribbon]{ggplot2::geom_ribbon()}}. For interval plots -\code{size} and \code{fatten} are passed to \code{\link[ggplot2:geom_pointrange]{ggplot2::geom_pointrange()}}.} +\code{size} and \code{fatten} are passed to \code{\link[ggplot2:geom_linerange]{ggplot2::geom_pointrange()}}.} } \value{ The plotting functions return a ggplot object that can be further diff --git a/man/PPC-loo.Rd b/man/PPC-loo.Rd index 05306e57..a59f9cab 100644 --- a/man/PPC-loo.Rd +++ b/man/PPC-loo.Rd @@ -106,11 +106,11 @@ PITs overlaid as a thicker dark line.} aesthetics. For \code{ppc_loo_pit_qq()} and \code{ppc_loo_pit_overlay()}, \code{size} and \code{alpha} are passed to \code{\link[ggplot2:geom_point]{ggplot2::geom_point()}} and \code{\link[ggplot2:geom_density]{ggplot2::geom_density()}}, respectively. For \code{ppc_loo_intervals()}, \code{size} -and \code{fatten} are passed to \code{\link[ggplot2:geom_pointrange]{ggplot2::geom_pointrange()}}. For +and \code{fatten} are passed to \code{\link[ggplot2:geom_linerange]{ggplot2::geom_pointrange()}}. For \code{ppc_loo_ribbon()}, \code{alpha} and \code{size} are passed to \code{\link[ggplot2:geom_ribbon]{ggplot2::geom_ribbon()}}.} -\item{trim}{Passed to \code{\link[ggplot2:stat_density]{ggplot2::stat_density()}}.} +\item{trim}{Passed to \code{\link[ggplot2:geom_density]{ggplot2::stat_density()}}.} \item{bw, adjust, kernel, n_dens}{Optional arguments passed to \code{\link[stats:density]{stats::density()}} to override default kernel density estimation diff --git a/man/bayesplot-colors.Rd b/man/bayesplot-colors.Rd index 228e1aa9..a6044eb4 100644 --- a/man/bayesplot-colors.Rd +++ b/man/bayesplot-colors.Rd @@ -75,7 +75,7 @@ etc.). The order of \code{x} and \code{y} matters, i.e., the color schemes guarantee that every possible mixed scheme will look good with every possible plot. \item \code{"brewer-x"}, replacing \code{x} with the name of a palette available from -\code{\link[RColorBrewer:brewer.pal]{RColorBrewer::brewer.pal()}} (e.g., \code{brewer-PuBuGn}). +\code{\link[RColorBrewer:ColorBrewer]{RColorBrewer::brewer.pal()}} (e.g., \code{brewer-PuBuGn}). } If you have a suggestion for a new color scheme please let us know via the diff --git a/man/bayesplot-extractors.Rd b/man/bayesplot-extractors.Rd index def3fa1c..bc96a18c 100644 --- a/man/bayesplot-extractors.Rd +++ b/man/bayesplot-extractors.Rd @@ -58,7 +58,7 @@ model parameters. If \code{pars} is omitted all parameters are included.} \item{regex_pars}{An optional \link[base:grep]{regular expression} to use for parameter selection. Can be specified instead of \code{pars} or in addition to \code{pars}. When using \code{pars} for tidy parameter selection, the \code{regex_pars} -argument is ignored since \link[tidyselect:select_helpers]{select helpers} +argument is ignored since \link[tidyselect:language]{select helpers} perform a similar function.} } \value{ diff --git a/man/bayesplot-helpers.Rd b/man/bayesplot-helpers.Rd index 2b6d5e95..b7c311fc 100644 --- a/man/bayesplot-helpers.Rd +++ b/man/bayesplot-helpers.Rd @@ -76,24 +76,24 @@ the first argument to \code{fun}.} vector.} \item{...}{For the various \code{vline_}, \code{hline_}, and \code{abline_} -functions, \code{...} is passed to \code{\link[ggplot2:geom_vline]{ggplot2::geom_vline()}}, -\code{\link[ggplot2:geom_hline]{ggplot2::geom_hline()}}, and \code{\link[ggplot2:geom_abline]{ggplot2::geom_abline()}}, +functions, \code{...} is passed to \code{\link[ggplot2:geom_abline]{ggplot2::geom_vline()}}, +\code{\link[ggplot2:geom_abline]{ggplot2::geom_hline()}}, and \code{\link[ggplot2:geom_abline]{ggplot2::geom_abline()}}, respectively, to control the appearance of the line(s). For functions ending in \verb{_bg}, \code{...} is passed to -\code{\link[ggplot2:element_rect]{ggplot2::element_rect()}}. +\code{\link[ggplot2:element]{ggplot2::element_rect()}}. For functions ending in \verb{_text} or \verb{_title}, \code{...} is passed -to \code{\link[ggplot2:element_text]{ggplot2::element_text()}}. +to \code{\link[ggplot2:element]{ggplot2::element_text()}}. For \code{xaxis_ticks} and \code{yaxis_ticks}, \code{...} is passed to -\code{\link[ggplot2:element_line]{ggplot2::element_line()}}. +\code{\link[ggplot2:element]{ggplot2::element_line()}}. For \code{overlay_function}, \code{...} is passed to -\code{\link[ggplot2:stat_function]{ggplot2::stat_function()}}.} +\code{\link[ggplot2:geom_function]{ggplot2::stat_function()}}.} \item{na.rm}{A logical scalar passed to the appropriate geom (e.g. -\code{\link[ggplot2:geom_vline]{ggplot2::geom_vline()}}). The default is \code{TRUE}.} +\code{\link[ggplot2:geom_abline]{ggplot2::geom_vline()}}). The default is \code{TRUE}.} \item{p}{The probability mass (in \verb{[0,1]}) to include in the interval.} @@ -107,12 +107,12 @@ or a string among \code{"right"}, \code{"left"}, \code{"top"}, equivalent to using \code{legend_none()}.} \item{on}{For functions modifying ggplot \link[ggplot2:theme]{theme} elements, -set \code{on=FALSE} to set the element to \code{\link[ggplot2:element_blank]{ggplot2::element_blank()}}. For +set \code{on=FALSE} to set the element to \code{\link[ggplot2:element]{ggplot2::element_blank()}}. For example, facet text can be removed by adding \code{facet_text(on=FALSE)}, or simply \code{facet_text(FALSE)} to a ggplot object. If \code{on=TRUE} (the default), then \code{...} can be used to customize the appearance of the theme element.} -\item{color, size}{Passed to \code{\link[ggplot2:element_line]{ggplot2::element_line()}}.} +\item{color, size}{Passed to \code{\link[ggplot2:element]{ggplot2::element_line()}}.} } \value{ A \strong{ggplot2} layer or \code{\link[ggplot2:theme]{ggplot2::theme()}} object that can be @@ -128,7 +128,7 @@ Convenience functions for adding to (and changing details of) ggplot objects \subsection{Add vertical, horizontal, and diagonal lines to plots}{ \itemize{ \item \code{vline_at()} and \code{hline_at()} return an object created by either -\code{\link[ggplot2:geom_vline]{ggplot2::geom_vline()}} or \code{\link[ggplot2:geom_hline]{ggplot2::geom_hline()}} that can be added to a +\code{\link[ggplot2:geom_abline]{ggplot2::geom_vline()}} or \code{\link[ggplot2:geom_abline]{ggplot2::geom_hline()}} that can be added to a ggplot object to draw a vertical or horizontal line (at one or several values). If \code{fun} is missing then the lines are drawn at the values in \code{v}. If \code{fun} is specified then the lines are drawn at the values returned by \code{fun(v)}. @@ -189,7 +189,7 @@ an existing plot (ggplot object) to add grid lines to the plot background. \subsection{Superimpose a function on an existing plot}{ \itemize{ -\item \code{overlay_function()} is a simple wrapper for \code{\link[ggplot2:stat_function]{ggplot2::stat_function()}} but +\item \code{overlay_function()} is a simple wrapper for \code{\link[ggplot2:geom_function]{ggplot2::stat_function()}} but with the \code{inherit.aes} argument fixed to \code{FALSE}. Fixing \code{inherit.aes=FALSE} will avoid potential errors due to the \code{\link[ggplot2:aes]{ggplot2::aes()}}thetic mapping used by certain \strong{bayesplot} plotting functions. diff --git a/man/bayesplot_theme_get.Rd b/man/bayesplot_theme_get.Rd index a107b2fe..fb346937 100644 --- a/man/bayesplot_theme_get.Rd +++ b/man/bayesplot_theme_get.Rd @@ -17,7 +17,7 @@ bayesplot_theme_replace(...) } \arguments{ \item{new}{The new theme (list of theme elements) to use. This is analogous -to the \code{new} argument to \code{\link[ggplot2:theme_set]{ggplot2::theme_set()}}.} +to the \code{new} argument to \code{\link[ggplot2:theme_get]{ggplot2::theme_set()}}.} \item{...}{A named list of theme settings.} } @@ -29,7 +29,7 @@ the \strong{ggplot2} versions of these functions. } \description{ These functions are the \strong{bayesplot} equivalent to -\strong{ggplot2}'s \code{\link[ggplot2:theme_set]{ggplot2::theme_set()}} and friends. They set, get, and update +\strong{ggplot2}'s \code{\link[ggplot2:theme_get]{ggplot2::theme_set()}} and friends. They set, get, and update the active theme but only apply them to \code{bayesplots}. The current/active theme is automatically applied to every \code{bayesplot} you draw. @@ -39,9 +39,9 @@ Use \code{bayesplot_theme_get()} to get the current \strong{bayesplot} theme and } \details{ \code{bayesplot_theme_set()} and friends only apply to \code{bayesplots}. -However, \code{\link[ggplot2:theme_set]{ggplot2::theme_set()}} can also be used to change the +However, \code{\link[ggplot2:theme_get]{ggplot2::theme_set()}} can also be used to change the \strong{bayesplot} theme. Currently, setting a theme with \code{ggplot2::theme_set()} -(other than the \strong{ggplot2} default \code{\link[ggplot2:theme_grey]{ggplot2::theme_grey()}}) will override +(other than the \strong{ggplot2} default \code{\link[ggplot2:ggtheme]{ggplot2::theme_grey()}}) will override the \strong{bayesplot} theme. } \examples{ diff --git a/man/theme_default.Rd b/man/theme_default.Rd index 4216a2c0..37ae1112 100644 --- a/man/theme_default.Rd +++ b/man/theme_default.Rd @@ -11,7 +11,7 @@ theme_default( } \arguments{ \item{base_size, base_family}{Base font size and family (passed to -\code{\link[ggplot2:theme_bw]{ggplot2::theme_bw()}}). It is possible to set \code{"bayesplot.base_size"} and +\code{\link[ggplot2:ggtheme]{ggplot2::theme_bw()}}). It is possible to set \code{"bayesplot.base_size"} and \code{"bayesplot.base_family"} via \code{\link[=options]{options()}} to change the defaults, which are \code{12} and \code{"serif"}, respectively.} } diff --git a/man/tidy-params.Rd b/man/tidy-params.Rd index 7a37ecce..75ce84ce 100644 --- a/man/tidy-params.Rd +++ b/man/tidy-params.Rd @@ -19,7 +19,7 @@ subset of elements to select. For example, using\preformatted{ param_range("bet would select parameters named \code{beta[1]}, \code{beta[2]}, and \code{beta[8]}. \code{param_range()} is only designed for the case that the indices are integers surrounded by brackets. If there are no brackets use -\link[tidyselect:select_helpers]{num_range()}.} +\link[tidyselect:language]{num_range()}.} \item{vars}{\code{NULL} or a character vector of parameter names to choose from. This is only needed for the atypical use case of calling the function as a @@ -41,7 +41,7 @@ would select parameters with names Parameter selection in the style of \strong{dplyr} and other tidyverse packages. } \details{ -As of version \verb{1.7.0}, \strong{bayesplot} allows the \code{pars} argument for \link[bayesplot:MCMC-overview]{MCMC plots} to use "tidy" variable selection (in the +As of version \verb{1.7.0}, \strong{bayesplot} allows the \code{pars} argument for \link[=MCMC-overview]{MCMC plots} to use "tidy" variable selection (in the style of the \strong{dplyr} package). The \code{\link[dplyr:vars]{vars()}} function is re-exported from \strong{dplyr} for this purpose. @@ -52,11 +52,11 @@ everything-but selection (\code{vars(-alpha)}), ranged selection \strong{Examples} section, below. When using \code{pars} for tidy parameter selection, the \code{regex_pars} argument is -ignored because \strong{bayesplot} supports using \link[tidyselect:select_helpers]{tidyselect helper functions} (\code{starts_with()}, \code{contains()}, +ignored because \strong{bayesplot} supports using \link[tidyselect:language]{tidyselect helper functions} (\code{starts_with()}, \code{contains()}, \code{num_range()}, etc.) for the same purpose. \strong{bayesplot} also exports some additional helper functions to help with parameter selection: \itemize{ -\item \code{param_range()}: like \code{\link[tidyselect:num_range]{num_range()}} but used +\item \code{param_range()}: like \code{\link[tidyselect:starts_with]{num_range()}} but used when parameter indexes are in brackets (e.g. \code{beta[2]}). \item \code{param_glue()}: for more complicated parameter names with multiple indexes (including variable names) inside the brackets @@ -65,7 +65,7 @@ indexes (including variable names) inside the brackets These functions can be used inside of \code{vars()}, \code{dplyr::select()}, and similar functions, just like the -\link[tidyselect:select_helpers]{tidyselect helper functions}. +\link[tidyselect:language]{tidyselect helper functions}. } \section{Extra Advice}{ From fb6f559afcf582a6e0c7b98305ef194481eb80fc Mon Sep 17 00:00:00 2001 From: jgabry Date: Thu, 3 Dec 2020 15:13:04 -0700 Subject: [PATCH 6/6] upload updated svgs for visual tests --- tests/figs/aesthetics/color-scheme-view-brewer-palette.svg | 2 +- tests/figs/aesthetics/color-scheme-view-default.svg | 2 +- tests/figs/aesthetics/color-scheme-view-mixed-scheme.svg | 2 +- tests/figs/aesthetics/color-scheme-view-scheme-specified.svg | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/figs/aesthetics/color-scheme-view-brewer-palette.svg b/tests/figs/aesthetics/color-scheme-view-brewer-palette.svg index 81d3fa7b..9c5c07fe 100644 --- a/tests/figs/aesthetics/color-scheme-view-brewer-palette.svg +++ b/tests/figs/aesthetics/color-scheme-view-brewer-palette.svg @@ -28,6 +28,6 @@ -brewer-Spectral +brewer-Spectral color_scheme_view (brewer palette) diff --git a/tests/figs/aesthetics/color-scheme-view-default.svg b/tests/figs/aesthetics/color-scheme-view-default.svg index df8e4aaa..b2304c26 100644 --- a/tests/figs/aesthetics/color-scheme-view-default.svg +++ b/tests/figs/aesthetics/color-scheme-view-default.svg @@ -28,6 +28,6 @@ -blue +blue color_scheme_view (default) diff --git a/tests/figs/aesthetics/color-scheme-view-mixed-scheme.svg b/tests/figs/aesthetics/color-scheme-view-mixed-scheme.svg index c18a7b09..2634ac93 100644 --- a/tests/figs/aesthetics/color-scheme-view-mixed-scheme.svg +++ b/tests/figs/aesthetics/color-scheme-view-mixed-scheme.svg @@ -28,6 +28,6 @@ -mix-red-blue +mix-red-blue color_scheme_view (mixed scheme) diff --git a/tests/figs/aesthetics/color-scheme-view-scheme-specified.svg b/tests/figs/aesthetics/color-scheme-view-scheme-specified.svg index 4728a30a..d89200c4 100644 --- a/tests/figs/aesthetics/color-scheme-view-scheme-specified.svg +++ b/tests/figs/aesthetics/color-scheme-view-scheme-specified.svg @@ -28,6 +28,6 @@ -red +red color_scheme_view (scheme specified)