Skip to content

Commit

Permalink
Update format.R
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jan 25, 2025
1 parent 7026cc2 commit 6777f42
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/format.R
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ format.marginaleffects_contrasts <- function(x, model = NULL, p_adjust = NULL, c
x[[i]] <- factor(x[[i]], levels = unique(x[[i]]))
}
# make sure filtering terms in `by` are factors, for data_arrange later
if (!is.null(by)) {
if (!is.null(by) && length(by)) {
for (i in by) {
if (i %in% colnames(dgrid) && i %in% colnames(x) && is.factor(dgrid[[i]])) {
if (i %in% colnames(dgrid) && i %in% colnames(x) && is.factor(dgrid[[i]]) && !is.factor(x[[i]])) { # nolint
x[[i]] <- factor(x[[i]], levels = unique(x[[i]]))
}
}
Expand Down

0 comments on commit 6777f42

Please sign in to comment.