Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 31, 2025

Custom effect size rules were not being properly reported as such, showing malformed text with a blank space instead of indicating they were custom rules.

Issue

When using custom rules with effectsize::rules(), the report output would show:

Effect sizes were labelled following  recommendations.

Notice the blank space between "following" and "recommendations."

Root Cause

The .text_effectsize() function in R/report_effectsize.R used a switch() statement to map known rule names like "cohen1988", "gignac2016", etc. When custom rules with unknown names (like "Unknown") were passed, the switch returned NULL for effsize_name, resulting in the malformed text.

Solution

Modified the logic in .text_effectsize() to check if the rule name is recognized. If the switch() statement returns NULL (indicating an unknown rule name), the function now correctly identifies it as a custom rule.

Before and After

Before:

library(report)
library(effectsize)

custom_rules <- effectsize::rules(1, c("tiny", "yeah okay"), name = "Unknown")
t.test(formula = extra ~ group, data = sleep) |>
  report(rules = custom_rules)
#> Effect sizes were labelled following  recommendations.

After:

library(report)
library(effectsize)

custom_rules <- effectsize::rules(1, c("tiny", "yeah okay"), name = "Unknown")
t.test(formula = extra ~ group, data = sleep) |>
  report(rules = custom_rules)
#> Effect sizes were labelled following a custom set of rules.

Testing

  • Added comprehensive unit tests for .text_effectsize() covering all predefined rules and custom rule scenarios
  • Enhanced integration tests for t-test reporting with custom rules
  • Verified no regression in existing functionality with built-in rules
  • All existing tests continue to pass

Fixes #458.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com>
Copilot AI changed the title [WIP] Custom rule not correctly reported as such Fix custom effect size rules not being correctly reported as custom rules Aug 31, 2025
Copilot finished work on behalf of rempsyc August 31, 2025 05:33
Copilot AI requested a review from rempsyc August 31, 2025 05:33
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.

Custom rule not correctly reported as such

2 participants