Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,11 @@ importFrom(dplyr,inner_join)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,n)
importFrom(dplyr,one_of)
importFrom(dplyr,pull)
importFrom(dplyr,rename)
importFrom(dplyr,select)
importFrom(dplyr,slice_min)
importFrom(dplyr,summarise)
importFrom(dplyr,top_n)
importFrom(dplyr,ungroup)
importFrom(dplyr,vars)
importFrom(ggplot2,"%+replace%")
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# bayesplot (development version)

* Replaced deprecated `dplyr` and `tidyselect` functions (`top_n`, `one_of`, `group_indices`) with their modern equivalents to ensure future compatibility. (#431)
* New "Example Gallery" vignette providing a visual overview of all plotting
functions with thumbnail example plots, organized by category (PPC, PPD, MCMC,
HMC/NUTS). (#437)
Comment on lines +3 to +6
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title/description focus on replacing deprecated dplyr/tidyselect functions (#431), but this change log entry also includes a new "Example Gallery" vignette and references a different issue/PR number (#437). Consider splitting the gallery work into a separate PR or updating the PR title/description to match the broader scope.

Copilot uses AI. Check for mistakes.
* Documentation added for all exported `*_data()` functions (#209)
* Improved documentation for `binwidth`, `bins`, and `breaks` arguments to clarify they are passed to `ggplot2::geom_area()` and `ggdist::stat_dots()` in addition to `ggplot2::geom_histogram()`
* Improved documentation for `freq` argument to clarify it applies to frequency polygons in addition to histograms
Expand Down
25 changes: 11 additions & 14 deletions R/mcmc-intervals.R
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ mcmc_intervals_data <- function(x,

rhat_tbl <- rhat %>%
mcmc_rhat_data() %>%
select(one_of("parameter"),
select(all_of("parameter"),
rhat_value = "value",
rhat_rating = "rating",
rhat_description = "description") %>%
Expand All @@ -663,7 +663,7 @@ mcmc_intervals_data <- function(x,
# Don't import `filter`: otherwise, you get a warning when using
# `devtools::load_all(".")` because stats also has a `filter` function

#' @importFrom dplyr inner_join one_of top_n
#' @importFrom dplyr inner_join all_of slice_min
#' @rdname MCMC-intervals
#' @export
mcmc_areas_data <- function(x,
Expand Down Expand Up @@ -736,14 +736,14 @@ mcmc_areas_data <- function(x,

# Find the density values closest to the point estimate
point_ests <- intervals %>%
select(one_of("parameter", "m"))
select(all_of(c("parameter", "m")))

point_centers <- data_inner %>%
inner_join(point_ests, by = "parameter") %>%
group_by(.data$parameter) %>%
mutate(diff = abs(.data$m - .data$x)) %>%
dplyr::top_n(1, -.data$diff) %>%
select(one_of("parameter", "x", "m")) %>%
dplyr::slice_min(.data$diff, n = 1) %>%
select(all_of(c("parameter", "x", "m"))) %>%
rename(center = "x") %>%
ungroup()

Expand All @@ -765,15 +765,15 @@ mcmc_areas_data <- function(x,
}

data <- dplyr::bind_rows(data_inner, data_outer, points) %>%
select(one_of("parameter", "interval", "interval_width",
"x", "density", "scaled_density")) %>%
select(all_of(c("parameter", "interval", "interval_width",
"x", "density", "scaled_density"))) %>%
# Density scaled so the highest in entire dataframe has height 1
mutate(plotting_density = .data$density / max(.data$density))

if (rlang::has_name(intervals, "rhat_value")) {
rhat_info <- intervals %>%
select(one_of("parameter", "rhat_value",
"rhat_rating", "rhat_description"))
select(all_of(c("parameter", "rhat_value",
"rhat_rating", "rhat_description")))
data <- inner_join(data, rhat_info, by = "parameter")
}
data
Expand Down Expand Up @@ -824,18 +824,15 @@ compute_column_density <- function(df, group_vars, value_var, ...) {
syms()

# Tuck away the subgroups to compute densities on into nested dataframes
sub_df <- dplyr::select(df, !!! group_cols, !! value_var)

group_df <- df %>%
dplyr::select(!!! group_cols, !! value_var) %>%
group_by(!!! group_cols)

by_group <- group_df %>%
split(dplyr::group_indices(group_df)) %>%
dplyr::group_split() %>%
lapply(pull, !! value_var)

nested <- df %>%
dplyr::distinct(!!! group_cols) %>%
nested <- dplyr::group_keys(group_df) %>%
mutate(data = by_group)

nested$density <- lapply(nested$data, compute_interval_density, ...)
Expand Down
11 changes: 10 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ navbar:
title: "bayesplot"

structure:
left: [home, vignettes, functions, news, pkgs, stan]
left: [home, gallery, vignettes, functions, news, pkgs, stan]
right: [search, bluesky, forum, github, lightswitch]

components:
gallery:
text: Gallery
href: articles/example-gallery.html
pkgs:
text: Other Packages
menu:
Expand All @@ -37,6 +40,12 @@ navbar:
href: https://mc-stan.org/shinystan

articles:
- title: "Example Gallery"
desc: >
A visual overview of all plotting functions available in **bayesplot**,
organized by category with thumbnail example plots.
contents:
- example-gallery
- title: "Getting Started"
desc: >
These vignettes provide an introduction to visualizing MCMC draws and
Expand Down
Loading
Loading