Skip to content

Conversation

@IndrajeetPatil
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings December 17, 2025 11:12
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 modernizes R syntax throughout the codebase by adopting newer language features introduced in R 4.1.0+ and contemporary dplyr patterns.

Key Changes:

  • Replaced function(x) with anonymous function shorthand \(x) syntax
  • Modernized dplyr code from group_by() %>% tally() %>% ungroup() to summarise(.by = ...) pattern
  • Replaced isFALSE() with ! operator for logical negation
  • Changed ifelse() to if-else for scalar conditional assignments
  • Updated GitHub Actions workflow for code coverage with better configuration

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
R/utils.R Updated error handler to use anonymous function shorthand \(e)
R/ggpiestats.R Changed isFALSE(paired) to !paired in condition
R/ggpiestats-ggbarstats-helpers.R Modernized .cat_counter to use .by parameter; updated .chisq_test_safe with new syntax and parameter handling
R/gghistostats.R Updated labels parameter to use anonymous function shorthand
R/ggbetweenstats-helpers.R Changed .f_switch from vectorized ifelse() to scalar if-else
R/ggbarstats.R Changed isFALSE(paired) to !paired in condition
R/extract-stats.R Converted multiple function definitions to anonymous function shorthand
.github/workflows/test-coverage.yaml Enhanced workflow with explicit permissions, updated runner, improved coverage reporting, and artifact upload

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

ungroup() %>%
arrange(desc({{ x }})) %>%
summarise(counts = n(), .by = c({{ y }}, {{ x }})) %>%
mutate(perc = (counts / sum(counts)) * 100, .by = {{ y }}) %>%
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The percentage calculation logic has changed. In the old code, percentages were calculated across all rows (after ungroup). In the new code, .by = {{ y }} causes percentages to be calculated within each y group. This is a semantic change that could affect the results.

If y is NULL (as in line 43 where .cat_counter(data, {{ y }}) is called with only one argument), the behavior might be the same, but when y is not NULL (as in line 12 where .cat_counter(data, {{ x }}, {{ y }}) is called), the percentages will be calculated per y group instead of overall.

To maintain the original behavior, remove the .by parameter from the mutate call.

Copilot uses AI. Check for mistakes.
arrange(desc({{ x }})) %>%
summarise(counts = n(), .by = c({{ y }}, {{ x }})) %>%
mutate(perc = (counts / sum(counts)) * 100, .by = {{ y }}) %>%
arrange(desc({{ x }}), {{ y }}) %>%
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The sorting behavior has changed. The old code only sorted by desc({{ x }}), but the new code sorts by both desc({{ x }}) and {{ y }}. This adds a secondary sort criterion that wasn't present before and could change the order of rows in the output, potentially affecting downstream code that relies on the specific ordering.

Copilot uses AI. Check for mistakes.
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.

2 participants