Skip to content

Replace deprecated dplyr/tidyselect functions#447

Closed
utkarshpawade wants to merge 4 commits intostan-dev:masterfrom
utkarshpawade:issue-431-replace-deprecated-dplyr
Closed

Replace deprecated dplyr/tidyselect functions#447
utkarshpawade wants to merge 4 commits intostan-dev:masterfrom
utkarshpawade:issue-431-replace-deprecated-dplyr

Conversation

@utkarshpawade
Copy link
Contributor

@utkarshpawade utkarshpawade commented Mar 10, 2026

This PR replaces deprecated functions from dplyr and tidyselect (dating back to the dplyr 1.0.0 lifecycle changes) to ensure future compatibility and suppress warnings during checks.

Changes

  • Replaced top_n() with slice_min().
  • Replaced one_of() with all_of().
  • Refactored group_indices() logic to use modern equivalents (group_keys() and group_split()), as group_indices() is deprecated when passed a grouped data frame.

- New vignette: example-gallery.Rmd with ~60 thumbnail plot cards
  organized in a CSS grid layout (PPC, PPD, MCMC, HMC/NUTS sections)
- Updated _pkgdown.yml: added Gallery navbar link and article section
- Added NEWS.md entry for the new gallery vignette
- Uses only built-in example data (no rstanarm dependency)
- Add gallery_card() and gallery_card_cond() helpers to reduce boilerplate HTML
- Use absolute URLs for all links
- Make thumbnail images clickable by wrapping them in anchor tags
- Add alt text (function name) and loading='lazy' to all images
- Clean up censoring setup chunk to remove unused variable
Copilot AI review requested due to automatic review settings March 10, 2026 13:35
@utkarshpawade utkarshpawade deleted the issue-431-replace-deprecated-dplyr branch March 10, 2026 13:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to modernize the codebase by removing deprecated dplyr/tidyselect usages (per #431) to prevent lifecycle warnings and improve forward compatibility, and it also introduces a new documentation “Example Gallery” surfaced in pkgdown.

Changes:

  • Replaced deprecated selection and ranking helpers (one_of(), top_n(), group_indices() pattern) with modern equivalents (all_of(), slice_min(), group_keys()/group_split()).
  • Added a new “Example Gallery” vignette that renders a thumbnail-based function overview.
  • Updated pkgdown config and NEWS to expose/document these updates.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
R/mcmc-intervals.R Updates deprecated dplyr/tidyselect usage in intervals/areas helpers.
NAMESPACE Adjusts imports to match new dplyr helpers.
vignettes/example-gallery.Rmd Adds a new vignette that generates a visual gallery of plotting functions.
_pkgdown.yml Adds a “Gallery” navbar item and registers the new article.
NEWS.md Documents the deprecation replacements and the new vignette entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3 to +6
* 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)
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.
yrep_cens <- matrix(rexp(n_cens * 50, rate = 0.5), nrow = 50)
group_cens <- factor(rep(c("A", "B"), each = n_cens / 2))
}
has_survival <- requireNamespace("survival", quietly = TRUE)
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.

has_survival is assigned twice in this chunk. The second has_survival <- requireNamespace("survival", quietly = TRUE) is redundant and can be removed to avoid confusion about whether the value can change within the chunk.

Suggested change
has_survival <- requireNamespace("survival", quietly = TRUE)

Copilot uses AI. Check for mistakes.
Comment on lines 735 to +739
half_point_width <- .004 * diff(x_lim)

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

slice_min() is being called with .data$diff as the first argument, but the first argument should be the data frame (provided by the pipe). As written this will error (or behave incorrectly) because a vector is passed as .data. Use slice_min(order_by = .data$diff, n = 1) (optionally set with_ties to match previous behavior).

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.63%. Comparing base (c817061) to head (52a3f0d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #447      +/-   ##
==========================================
- Coverage   98.63%   98.63%   -0.01%     
==========================================
  Files          35       35              
  Lines        5860     5858       -2     
==========================================
- Hits         5780     5778       -2     
  Misses         80       80              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants