Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: report
Type: Package
Title: Automated Reporting of Results and Statistical Models
Version: 0.6.1.2
Version: 0.6.1.3
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Bug fixes

* Added regression tests for `reformulate()` formula edge cases to prevent future issues (#391)
* Fixed issue with missing effect size for the Intercept term in type 3 anova tables (#451)

# report 0.6.1
Expand Down
43 changes: 43 additions & 0 deletions tests/testthat/test-report.lm.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,46 @@ test_that("report.lm - lm intercept-only", {
out <- suppressWarnings(report(model_io, verbose = FALSE))
expect_snapshot(variant = "windows", out)
})


test_that("report.lm - reformulate formula edge cases", {
# Test various reformulate scenarios to prevent regression of issue #391

# Test 1: Simple reformulate case
model_reform <- lm(reformulate(c("wt", "hp"), "mpg"), data = mtcars)
result_reform <- report(model_reform)
expect_s3_class(result_reform, "report")
expect_true(any(grepl("wt", as.character(result_reform))))
expect_true(any(grepl("hp", as.character(result_reform))))

# Test 2: Reformulate with formula() wrapper (exact issue case)
model_formula <- lm(formula(reformulate(c("wt", "hp"), "mpg")), data = mtcars)
result_formula <- report(model_formula)
expect_s3_class(result_formula, "report")
expect_true(any(grepl("wt", as.character(result_formula))))
expect_true(any(grepl("hp", as.character(result_formula))))

# Test 3: Reformulate with interaction terms
model_interact <- lm(reformulate(c("wt", "hp", "wt:hp"), "mpg"), data = mtcars)
result_interact <- report(model_interact)
expect_s3_class(result_interact, "report")
expect_true(any(grepl("wt", as.character(result_interact))))
expect_true(any(grepl("hp", as.character(result_interact))))

# Test 4: Reformulate without intercept
model_no_int <- lm(reformulate(c("wt", "hp"), "mpg", intercept = FALSE), data = mtcars)
result_no_int <- report(model_no_int)
expect_s3_class(result_no_int, "report")
expect_true(any(grepl("wt", as.character(result_no_int))))
expect_true(any(grepl("hp", as.character(result_no_int))))

# Test 5: Verify format_formula works correctly with reformulate
formatted_reform <- format_formula(model_reform)
formatted_normal <- format_formula(lm(mpg ~ wt + hp, data = mtcars))
expect_equal(formatted_reform, formatted_normal)

# Test 6: Verify report_model works correctly with reformulate
model_report_reform <- report_model(model_reform)
model_report_normal <- report_model(lm(mpg ~ wt + hp, data = mtcars))
expect_equal(as.character(model_report_reform), as.character(model_report_normal))
})