From bb8f890bd8c48b2e36d9ab4d97f54f74fb1290ff Mon Sep 17 00:00:00 2001 From: Paul Buerkner Date: Wed, 10 Feb 2021 16:31:00 +0100 Subject: [PATCH] prevent information loss in the data output of conditional_effects --- R/conditional_effects.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/R/conditional_effects.R b/R/conditional_effects.R index 7a0a04b76..8d76ea3b6 100644 --- a/R/conditional_effects.R +++ b/R/conditional_effects.R @@ -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) {