Skip to content

Commit

Permalink
group column in hypotheses() FUN
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Sep 12, 2023
1 parent 0e3850e commit bb07daa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# News

## dev

* `hypotheses()`: The `FUN` argument handles `group` columns gracefully.

## 0.15.0

New:
Expand Down
8 changes: 7 additions & 1 deletion R/hypotheses.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -234,6 +236,9 @@ hypotheses <- function(
} else {
attr(out, "label") <- tmp$term
}
if ("group" %in% colnames(tmp)) {
attr(out, "grouplab") <- tmp[["group"]]
}
return(out)
}

Expand Down Expand Up @@ -276,6 +281,7 @@ hypotheses <- function(
std.error = se)
}
}
out[["group"]] <- attr(b, "grouplab")

out <- get_ci(
out,
Expand Down

0 comments on commit bb07daa

Please sign in to comment.