Skip to content

Commit

Permalink
Replace colnames() with names() in tidy.poly(). Fixes #497. (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpghayes committed Oct 1, 2018
2 parents 7fd7d07 + 7afa254 commit 411e544
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Expand Up @@ -45,6 +45,10 @@ The following have all been deprecated in favor of `broom.mixed`:
- `tidy.lme()`, `glance.lme()`, `augment.lme()`
- `tidy.stanreg()`, `glance.stanreg()`

## Other changes

- Bug fix for tidy.polr for incorrectly using colnames. (#498)

# broom 0.5.0

Tidiers now return `tibble::tibble()`s. This release also includes several new tidiers, new vignettes and a large number of bugfixes. We've also begun to more rigorously define tidier specifications: we've laid part of the groundwork for stricter and more consistent tidying, but the new tidier specifications are not yet complete. These will appear in the next release.
Expand Down
4 changes: 4 additions & 0 deletions R/mass-polr-tidiers.R
Expand Up @@ -32,6 +32,10 @@ process_polr <- function(ret, x, conf.int = FALSE, conf.level = .95,

if (conf.int) {
CI <- suppressMessages(trans(stats::confint(x, level = conf.level)))
if (!is.matrix(CI)) {
CI <- rbind(CI)
rownames(CI) <- names(coef(x))
}
colnames(CI) <- c("conf.low", "conf.high")
CI <- as.data.frame(CI)
CI$term <- rownames(CI)
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-mass-polr.R
Expand Up @@ -7,6 +7,7 @@ skip_if_not_installed("MASS")
library(MASS)

fit <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing)
fit2 <- polr(Sat ~ Freq, data = housing)

test_that("MASS::polr tidier arguments", {
check_arguments(tidy.polr)
Expand All @@ -18,12 +19,15 @@ test_that("tidy.polr", {

td <- tidy(fit, quick = TRUE)
td2 <- tidy(fit, conf.int = TRUE, exponentiate = TRUE)
td3 <- tidy(fit2, conf.int = TRUE, exponentiate = TRUE)

check_tidy_output(td, strict = FALSE)
check_tidy_output(td2, strict = FALSE)
check_tidy_output(td3, strict = FALSE)

check_dims(td, expected_cols = 3)
check_dims(td2, expected_cols = 7)
check_dims(td3, expected_cols = 7)
})

test_that("glance.polr", {
Expand Down

0 comments on commit 411e544

Please sign in to comment.