Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 21, 2024
1 parent d1976fa commit 9cd46e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 11 additions & 8 deletions R/find_formula.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ find_formula.data.frame <- function(x, verbose = TRUE, ...) {
find_formula.aovlist <- function(x, verbose = TRUE, ...) {
f <- attr(x, "terms", exact = TRUE)
attributes(f) <- NULL
.find_formula_return(list(conditional = f))
.find_formula_return(list(conditional = f), verbose = verbose)
}


Expand Down Expand Up @@ -440,7 +440,7 @@ find_formula.systemfit <- function(x, verbose = TRUE, ...) {
if (length(f) > 1L) {
attr(f, "is_mv") <- "1"
}
.find_formula_return(f)
.find_formula_return(f, verbose = verbose)
}


Expand Down Expand Up @@ -548,14 +548,17 @@ find_formula.averaging <- function(x, verbose = TRUE, ...) {

#' @export
find_formula.glht <- function(x, verbose = TRUE, ...) {
.find_formula_return(list(conditional = stats::formula(x$model)))
.find_formula_return(list(conditional = stats::formula(x$model)), verbose = verbose)
}


#' @export
find_formula.joint <- function(x, verbose = TRUE, ...) {
f <- stats::formula(x)
.find_formula_return(list(conditional = f$lformula, survival = f$sformula))
.find_formula_return(
list(conditional = f$lformula, survival = f$sformula),
verbose = verbose
)
}


Expand Down Expand Up @@ -629,7 +632,7 @@ find_formula.afex_aov <- function(x, verbose = TRUE, ...) {

#' @export
find_formula.mira <- function(x, verbose = TRUE, ...) {
.find_formula_return(find_formula(x$analyses[[1]]))
.find_formula_return(find_formula(x$analyses[[1]]), verbose = verbose)
}


Expand Down Expand Up @@ -1181,7 +1184,7 @@ find_formula.DirichletRegModel <- function(x, verbose = TRUE, ...) {
names(out)[2] <- "precision"
}

.find_formula_return(out)
.find_formula_return(out, verbose = verbose)
}


Expand Down Expand Up @@ -1576,7 +1579,7 @@ find_formula.stanmvreg <- function(x, verbose = TRUE, ...) {
f <- stats::formula(x)
mv_formula <- lapply(f, .get_stanmv_formula)
attr(mv_formula, "is_mv") <- "1"
.find_formula_return(mv_formula)
.find_formula_return(mv_formula, verbose = verbose)
}


Expand Down Expand Up @@ -1907,7 +1910,7 @@ find_formula.model_fit <- function(x, verbose = TRUE, ...) {
return(NULL)
}

formula_ok(f)
formula_ok(f, verbose = verbose)
class(f) <- c("insight_formula", class(f))
f
}
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-find_formula.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ test_that("formula warns when using backticks", {
data(mtcars)
colnames(mtcars)[1] <- "1_mpg"
m <- lm(`1_mpg` ~ gear, data = mtcars)
expect_false(expect_warning(formula_ok(m), regex = "syntactically"))
expect_warning(expect_false(formula_ok(m)), regex = "syntactically")
expect_silent(expect_true(formula_ok(m, checks = "dollar")))
expect_error(formula_ok(m, checks = c("dollar", "test")), regex = "invalid options")
})

0 comments on commit 9cd46e7

Please sign in to comment.