handling empty formula

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-11-15 21:57:38 +01:00
parent 269658ef17
commit f4be547ed0
No known key found for this signature in database

View file

@ -35,7 +35,7 @@ regression_model <- function(data,
args.list = NULL,
fun = NULL,
vars = NULL) {
if (!is.null(formula.str)) {
if (!is.null(formula.str) | formula.str != "") {
formula.str <- glue::glue(formula.str)
} else {
assertthat::assert_that(outcome.str %in% names(data),
@ -62,11 +62,10 @@ regression_model <- function(data,
} else if (is.factor(data[[outcome.str]])) {
if (length(levels(data[[outcome.str]])) == 2) {
fun <- "stats::glm"
args.list = list(family = binomial(link = "logit"))
args.list <- list(family = binomial(link = "logit"))
} else if (length(levels(data[[outcome.str]])) > 2) {
fun <- "MASS::polr"
args.list = list(
args.list <- list(
Hess = TRUE,
method = "logistic"
)
@ -76,7 +75,6 @@ regression_model <- function(data,
} else {
stop("Output variable should be either numeric or factor for auto.mode")
}
}
assertthat::assert_that("character" %in% class(fun),