diff --git a/DESCRIPTION b/DESCRIPTION index ca8c36a2..6420507e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: report Type: Package Title: Automated Reporting of Results and Statistical Models -Version: 0.6.3.1 +Version: 0.6.3.2 Authors@R: c(person(given = "Dominique", family = "Makowski", diff --git a/NEWS.md b/NEWS.md index 5a417704..1bdadae8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ Bug fixes +* Fixed custom effect size rules not being correctly reported as custom rules (#458) * Fix `report()` crash when character vector has only one unique value (#578). # report 0.6.3 diff --git a/R/report_effectsize.R b/R/report_effectsize.R index c17c9154..674b2f20 100644 --- a/R/report_effectsize.R +++ b/R/report_effectsize.R @@ -102,11 +102,17 @@ print.report_effectsize <- function(x, ...) { field2013 = "Field's (2013)", landis1977 = "Landis' (1977)" ) - effect_text <- paste0( - "Effect sizes were labelled following ", - effsize_name, - " recommendations." - ) + if (is.null(effsize_name)) { + effect_text <- paste0( + "Effect sizes were labelled following a custom set of rules." + ) + } else { + effect_text <- paste0( + "Effect sizes were labelled following ", + effsize_name, + " recommendations." + ) + } } else { effect_text <- paste0( "Effect sizes were labelled following a custom set of rules." diff --git a/tests/testthat/test-report.htest-t-test.R b/tests/testthat/test-report.htest-t-test.R index 1ffb3e2d..0612b503 100644 --- a/tests/testthat/test-report.htest-t-test.R +++ b/tests/testthat/test-report.htest-t-test.R @@ -160,4 +160,15 @@ test_that("report.htest-t-test", { variant = "windows", report_effectsize(x, rules = "gignac2016", type = "g") ) + + # custom rules --------------------- + custom_rules <- effectsize::rules(1, c("tiny", "yeah okay"), name = "Unknown") + expect_snapshot( + variant = "windows", + report_effectsize(x, rules = custom_rules) + ) + expect_snapshot( + variant = "windows", + report(x, rules = custom_rules) + ) }) diff --git a/tests/testthat/test-text_effectsize.R b/tests/testthat/test-text_effectsize.R new file mode 100644 index 00000000..21716c58 --- /dev/null +++ b/tests/testthat/test-text_effectsize.R @@ -0,0 +1,66 @@ +test_that(".text_effectsize handles custom rules correctly", { + # Test NULL input + expect_equal(report:::.text_effectsize(NULL), "") + + # Test known predefined rules + expect_equal( + report:::.text_effectsize("cohen1988"), + "Effect sizes were labelled following Cohen's (1988) recommendations." + ) + expect_equal( + report:::.text_effectsize("sawilowsky2009"), + "Effect sizes were labelled following Savilowsky's (2009) recommendations." + ) + expect_equal( + report:::.text_effectsize("gignac2016"), + "Effect sizes were labelled following Gignac's (2016) recommendations." + ) + expect_equal( + report:::.text_effectsize("funder2019"), + "Effect sizes were labelled following Funder's (2019) recommendations." + ) + expect_equal( + report:::.text_effectsize("lovakov2021"), + "Effect sizes were labelled following Lovakov's (2021) recommendations." + ) + expect_equal( + report:::.text_effectsize("evans1996"), + "Effect sizes were labelled following Evans's (1996) recommendations." + ) + expect_equal( + report:::.text_effectsize("chen2010"), + "Effect sizes were labelled following Chen's (2010) recommendations." + ) + expect_equal( + report:::.text_effectsize("field2013"), + "Effect sizes were labelled following Field's (2013) recommendations." + ) + expect_equal( + report:::.text_effectsize("landis1977"), + "Effect sizes were labelled following Landis' (1977) recommendations." + ) + + # Test custom rule names (strings not in predefined list) + expect_equal( + report:::.text_effectsize("Unknown"), + "Effect sizes were labelled following a custom set of rules." + ) + expect_equal( + report:::.text_effectsize("MyCustomRules"), + "Effect sizes were labelled following a custom set of rules." + ) + expect_equal( + report:::.text_effectsize("CustomRule2024"), + "Effect sizes were labelled following a custom set of rules." + ) + + # Test non-character input (should also return custom rules text) + expect_equal( + report:::.text_effectsize(123), + "Effect sizes were labelled following a custom set of rules." + ) + expect_equal( + report:::.text_effectsize(list()), + "Effect sizes were labelled following a custom set of rules." + ) +}) \ No newline at end of file