diff --git a/NEWS.md b/NEWS.md index 6019e4bec..2cc79ceef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,9 +2,12 @@ * Moved forward with deprecation of tidiers for objects from the sp package. See resources linked in [tidymodels/broom#1142](https://github.com/tidymodels/broom/issues/1142) for more information on migration from retiring spatial packages. +* Corrected confidence interval values for precision components in `tidy.betareg()` output (#1169). + +* Fixed bug in tidier for `car::linearHypothesis()` output with long formulas (#1171). + * Added support for columns `adj.r.squared` and `npar` in `glance()` method for objects outputted from `mgcv::gam()` (#1172). -* Corrected confidence interval values for precision components in `tidy.betareg()` output. # broom 1.0.5 diff --git a/R/stats-anova-tidiers.R b/R/stats-anova-tidiers.R index 3fcd59667..5a9d53a19 100644 --- a/R/stats-anova-tidiers.R +++ b/R/stats-anova-tidiers.R @@ -113,7 +113,7 @@ tidy.anova <- function(x, ...) { # Drop unrestricted model (not interesting in linear hypothesis tests) # Use formula to subset if available (e.g. with car::linearHypothesis) if (length(mod_lines) != 0) { - idx <- sub(".*: ", "", strsplit(mod_lines, "\n")[[1]]) + idx <- sub("Model \\d*: ", "", strsplit(mod_lines, "\\nModel \\d*: ")[[1]]) idx <- idx != "restricted model" ret <- ret[idx, , drop = FALSE] } diff --git a/tests/testthat/test-car.R b/tests/testthat/test-car.R index e3561494a..e335fadc5 100644 --- a/tests/testthat/test-car.R +++ b/tests/testthat/test-car.R @@ -84,3 +84,16 @@ test_that("tidy car::Anova coxph", { check_dims(td2, expected_rows = 2, expected_cols = 5) check_dims(td3, expected_rows = 2, expected_cols = 4) }) + +test_that("tidy car::linearHypothesis with long formulas (#1171)", { + reg_long <- + lm( + Fertility ~ Agriculture + Examination + Education + Catholic + Infant.Mortality, + data = swiss + ) + + test_long <- car::linearHypothesis(reg_long, hypothesis.matrix = c(0,1, 0, 0, 0, -1)) + + td <- broom::tidy(test_long) + check_dims(td, expected_rows = 1, expected_cols = 10) +})