Skip to content

Commit eea030b

Browse files
authored
Merge branch 'master' into fix/geom-function-and-override-aes-449
2 parents d99e0d2 + b1cb851 commit eea030b

34 files changed

+632
-591
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
env:
3030
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
3131
R_KEEP_PKG_SOURCE: yes
32+
R_VERSION_TYPE: ${{ matrix.config.r }}
3233

3334
steps:
3435
- uses: actions/checkout@v6

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ SystemRequirements: pandoc (>= 1.12.3), pandoc-citeproc
3030
Depends:
3131
R (>= 4.1.0)
3232
Imports:
33-
dplyr (>= 0.8.0),
33+
dplyr (>= 1.0.0),
3434
ggplot2 (>= 3.4.0),
3535
ggridges (>= 0.5.5),
3636
glue,
37+
lifecycle,
3738
posterior,
3839
reshape2,
39-
rlang (>= 0.3.0),
40+
rlang (>= 1.0.0),
4041
stats,
4142
tibble (>= 2.0.0),
4243
tidyr,

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,6 @@ importFrom(dplyr,top_n)
226226
importFrom(dplyr,ungroup)
227227
importFrom(dplyr,vars)
228228
importFrom(ggplot2,"%+replace%")
229+
importFrom(lifecycle,deprecate_warn)
230+
importFrom(lifecycle,deprecated)
231+
importFrom(lifecycle,is_present)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# bayesplot (development version)
22

3+
* Fix assignment-in-call bug in `mcmc_rank_ecdf()` (#).
4+
* Replaced deprecated `dplyr` and `tidyselect` functions (`top_n`, `one_of`, `group_indices`) with their modern equivalents to ensure future compatibility. (#431)
35
* Documentation added for all exported `*_data()` functions (#209)
46
* 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()`
57
* Improved documentation for `freq` argument to clarify it applies to frequency polygons in addition to histograms

R/bayesplot-helpers.R

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,19 +446,28 @@ plot_bg <- function(on = TRUE, ...) {
446446

447447
#' @rdname bayesplot-helpers
448448
#' @export
449-
#' @param color,size Passed to [ggplot2::element_line()].
450-
#'
451-
grid_lines <- function(color = "gray50", size = 0.2) {
449+
#' @param color,linewidth Passed to [ggplot2::element_line()].
450+
#' @param size `r lifecycle::badge("deprecated")` Use `linewidth` instead.
451+
#'
452+
grid_lines <- function(color = "gray50", linewidth = 0.2, size = deprecated()) {
453+
if (lifecycle::is_present(size)) {
454+
lifecycle::deprecate_warn(
455+
"1.16.0",
456+
"grid_lines(size)",
457+
"grid_lines(linewidth)"
458+
)
459+
linewidth <- size
460+
}
452461
theme(
453-
panel.grid.major = element_line(color = color, linewidth = size),
454-
panel.grid.minor = element_line(color = color, linewidth = size * 0.5)
462+
panel.grid.major = element_line(color = color, linewidth = linewidth),
463+
panel.grid.minor = element_line(color = color, linewidth = linewidth * 0.5)
455464
)
456465
}
457466

458-
grid_lines_y <- function(color = "gray50", size = 0.2) {
467+
grid_lines_y <- function(color = "gray50", linewidth = 0.2) {
459468
theme(
460-
panel.grid.major.y = element_line(color = color, linewidth = size),
461-
panel.grid.minor.y = element_line(color = color, linewidth = size * 0.5)
469+
panel.grid.major.y = element_line(color = color, linewidth = linewidth),
470+
panel.grid.minor.y = element_line(color = color, linewidth = linewidth * 0.5)
462471
)
463472
}
464473

R/bayesplot-package.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#'
66
#' @import ggplot2 stats rlang
77
#' @importFrom dplyr %>% summarise group_by select
8+
#' @importFrom lifecycle deprecated deprecate_warn is_present
89
#'
910
#' @description
1011
#' \if{html}{

R/helpers-gg.R

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@ geom_ignore <- function(...) {
2424

2525
#' Add new aesthetic mappings to a list of aesthetic mappings
2626
#'
27-
#' @param mapping a list of `uneval` aesthetic mappings (created by `aes_()`)
28-
#' @param ... additional mappings to add, e.g., `color = ~ parameter`
27+
#' @param mapping a list of `uneval` aesthetic mappings (created by `aes()`)
28+
#' @param ... additional mappings to add using `.data$` syntax
2929
#' @return the updated list
3030
#' @noRd
31-
modify_aes_ <- function(mapping, ...) {
32-
utils::modifyList(mapping, aes_(...))
33-
}
34-
35-
#' Same as `modify_aes_` but using `aes()` instead of `aes_()` (now deprecated).
36-
#' Often `...` will need to contain expression of the form `.data$x` to avoid R cmd check warnings
37-
#' @noRd
3831
modify_aes <- function(mapping, ...) {
3932
utils::modifyList(mapping, aes(...))
4033
}

R/mcmc-diagnostics.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
#' (p <- mcmc_acf_bar(x, pars = c("alpha", "beta[1]")))
7878
#'
7979
#' # add horiztonal dashed line at 0.5
80-
#' p + hline_at(0.5, linetype = 2, size = 0.15, color = "gray")
80+
#' p + hline_at(0.5, linetype = 2, linewidth = 0.15, color = "gray")
8181
#' }
8282
#'
8383
#' # fake rhat values to use for demonstration

R/mcmc-distributions.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ mcmc_dots_by_chain <- function(
489489
data <- melt_mcmc(x, value.name = "value")
490490
n_param <- num_params(data)
491491

492-
graph <- ggplot(data, aes(x = ~ value)) +
492+
graph <- ggplot(data, aes(x = .data$value)) +
493493
geom_histogram(
494494
set_hist_aes(freq),
495495
fill = get_color("mid"),

R/mcmc-intervals.R

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ mcmc_intervals_data <- function(x,
647647

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

666-
#' @importFrom dplyr inner_join one_of top_n
666+
#' @importFrom dplyr inner_join all_of slice_min
667667
#' @rdname MCMC-intervals
668668
#' @export
669669
mcmc_areas_data <- function(x,
@@ -736,14 +736,14 @@ mcmc_areas_data <- function(x,
736736

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

741741
point_centers <- data_inner %>%
742742
inner_join(point_ests, by = "parameter") %>%
743743
group_by(.data$parameter) %>%
744744
mutate(diff = abs(.data$m - .data$x)) %>%
745-
dplyr::top_n(1, -.data$diff) %>%
746-
select(one_of("parameter", "x", "m")) %>%
745+
dplyr::slice_min(order_by = .data$diff, n = 1) %>%
746+
select(all_of(c("parameter", "x", "m"))) %>%
747747
rename(center = "x") %>%
748748
ungroup()
749749

@@ -765,15 +765,15 @@ mcmc_areas_data <- function(x,
765765
}
766766

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

773773
if (rlang::has_name(intervals, "rhat_value")) {
774774
rhat_info <- intervals %>%
775-
select(one_of("parameter", "rhat_value",
776-
"rhat_rating", "rhat_description"))
775+
select(all_of(c("parameter", "rhat_value",
776+
"rhat_rating", "rhat_description")))
777777
data <- inner_join(data, rhat_info, by = "parameter")
778778
}
779779
data
@@ -824,18 +824,15 @@ compute_column_density <- function(df, group_vars, value_var, ...) {
824824
syms()
825825

826826
# Tuck away the subgroups to compute densities on into nested dataframes
827-
sub_df <- dplyr::select(df, !!! group_cols, !! value_var)
828-
829827
group_df <- df %>%
830828
dplyr::select(!!! group_cols, !! value_var) %>%
831829
group_by(!!! group_cols)
832830

833831
by_group <- group_df %>%
834-
split(dplyr::group_indices(group_df)) %>%
832+
dplyr::group_split() %>%
835833
lapply(pull, !! value_var)
836834

837-
nested <- df %>%
838-
dplyr::distinct(!!! group_cols) %>%
835+
nested <- dplyr::group_keys(group_df) %>%
839836
mutate(data = by_group)
840837

841838
nested$density <- lapply(nested$data, compute_interval_density, ...)

0 commit comments

Comments
 (0)