diff --git a/DESCRIPTION b/DESCRIPTION index e90c728ab..2565df999 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: marginaleffects Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests -Version: 0.15.0 +Version: 0.15.0.9000 Authors@R: c(person(given = "Vincent", family = "Arel-Bundock", diff --git a/NEWS.md b/NEWS.md index 927cd883d..342b09331 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # News +## dev + +* `hypotheses()`: The `FUN` argument handles `group` columns gracefully. + ## 0.15.0 New: diff --git a/R/hypotheses.R b/R/hypotheses.R index bc8945024..2df25809d 100644 --- a/R/hypotheses.R +++ b/R/hypotheses.R @@ -202,9 +202,11 @@ hypotheses <- function( if (!all(c("term", "estimate") %in% colnames(model))) { insight::format_error("The model object is a data.frame but doesn't contain the columns 'term' or 'estimate'. Make sure these columns are present") } - return(model[, c("term", "estimate")]) + idx <- intersect(colnames(model), c("term", "group", "estimate")) + return(model[, idx]) } else { param <- insight::get_parameters(model, ...) + idx <- intersect(colnames(model), c("term", "group", "estimate")) colnames(param)[1:2] <- c("term", "estimate") return(param) } @@ -234,6 +236,9 @@ hypotheses <- function( } else { attr(out, "label") <- tmp$term } + if ("group" %in% colnames(tmp)) { + attr(out, "grouplab") <- tmp[["group"]] + } return(out) } @@ -276,6 +281,7 @@ hypotheses <- function( std.error = se) } } + out[["group"]] <- attr(b, "grouplab") out <- get_ci( out,