Skip to content

Commit

Permalink
prevent information loss in the data output of conditional_effects
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-buerkner committed Feb 10, 2021
1 parent 5eca085 commit bb8f890
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/conditional_effects.R
Original file line number Diff line number Diff line change
Expand Up @@ -418,20 +418,21 @@ conditional_effects.brmsterms <- function(
}
}

cond_data <- add_effects__(cond_data, effects)
first_numeric <- types[1] %in% "numeric"
second_numeric <- types[2] %in% "numeric"
both_numeric <- first_numeric && second_numeric
if (second_numeric && !surface) {
# can only be converted to factor after having called method
# only convert 'effect2__' to factor so that the original
# second effect variable remains unchanged in the data
mde2 <- round(cond_data[[effects[2]]], 2)
levels2 <- sort(unique(mde2), TRUE)
cond_data[[effects[2]]] <- factor(mde2, levels = levels2)
cond_data$effect2__ <- factor(mde2, levels = levels2)
labels2 <- names(int_conditions[[effects[2]]])
if (length(labels2) == length(levels2)) {
levels(cond_data[[effects[2]]]) <- labels2
levels(cond_data$effect2__) <- labels2
}
}
cond_data <- add_effects__(cond_data, effects)

spag <- NULL
if (first_numeric && spaghetti) {
Expand Down

0 comments on commit bb8f890

Please sign in to comment.