Skip to content
Merged
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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# report (devel)

Bug fixes

* Fixed an issue in `report()` where the reference level for logical predictors was incorrectly displayed as `[?]` instead of `FALSE` for the intercept (@M-Colley, #598).

# report 0.6.4

New features
Expand Down
7 changes: 7 additions & 0 deletions R/report_intercept.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ print.report_intercept <- function(x, ...) {
intercept_text,
paste0(col, " = ", levels(intercept_data[[col]])[ref_level])
)
} else if (is.logical(intercept_data[[col]])) {
logical_factor <- as.factor(intercept_data[[col]])
ref_level <- .find_reference_level(logical_factor)
intercept_text <- c(
intercept_text,
paste0(col, " = ", levels(logical_factor)[ref_level])
)
} else {
intercept_text <- c(intercept_text, paste0(col, " = [?]"))
}
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-report_intercept.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,14 @@ test_that("reflevel", {
as.character(report_intercept(m3)),
"The model's intercept, corresponding to f = 1, is at 0.17 (95% CI [-0.47, 0.81], t(27) = 0.55, p = 0.584)."
)

# Logical predictor
on.exit(data("mtcars"), add = TRUE)

mtcars$more_than_4_cyl <- as.logical(mtcars$cyl > 4)
m4 <- lm(mpg ~ more_than_4_cyl, data = mtcars)
expect_identical(
as.character(report_intercept(m4)),
"The model's intercept, corresponding to more_than_4_cyl = FALSE, is at 26.66 (95% CI [24.41, 28.92], t(30) = 24.16, p < .001)."
)
})
Loading