Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for glm output from car #325

Merged
merged 1 commit into from Jun 7, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions R/anova_tidiers.R
Expand Up @@ -20,6 +20,10 @@
#'
#' @details Note that the "term" column of an ANOVA table can come with
#' leading or trailing whitespace, which this tidying method trims.
#'
#' Note that \code{Anova} from \pkg{car} (perhaps counter-intuively) outputs an
#' object of class \code{anova} for generalized linear models. These objects are
#' also supported.
#'
#' @examples
#'
Expand Down Expand Up @@ -61,6 +65,8 @@ tidy.anova <- function(x, ...) {
"Pr..Chi." = "p.value",
"p.value" = "p.value",
"Chi.sq" = "statistic",
"LR.Chisq" = "statistic",
"LR Chisq" = "statistic",
"edf" = "edf",
"Ref.df" = "ref.df"
)
Expand Down
4 changes: 4 additions & 0 deletions man/anova_tidiers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions tests/testthat/test-glm.R
Expand Up @@ -5,3 +5,25 @@ test_that("glance.glm works", {
gl <- glance(g)
check_tidy(gl, exp.col = 7)
})

test_that(
"tidy.anova from car", {
model <- glm(am ~ mpg, mtcars, family = "binomial")
car_output <- car::Anova(model, test.statistic = "LR")

expect_equal(
object = tidy(car_output),
expected = structure(
list(
term = "mpg",
statistic = 13.5545656286209,
df = 1,
p.value = 0.000231727053726745
),
class = "data.frame",
.Names = c("term", "statistic", "df", "p.value"),
row.names = c(NA, -1L)
)
)
}
)