fsolt / dotwhisker

Dot-and-Whisker Plots of Regression Results
https://fsolt.org/dotwhisker/
Other
57 stars 10 forks source link

add_brackets fails with lmer models #95

Closed misea closed 2 years ago

misea commented 4 years ago

But it works if you drop the "group" column created by tidy(lmer_model) before plotting

library(lme4)
data("mtcars")

m1 <- lm(mpg~wt+disp + cyl, data = mtcars)
{dwplot(m1)} %>% add_brackets(list(c("G1", "wt", "wt"), c("G2", "disp", "disp")))

# Looks good

m2 <- lmer(mpg~wt+disp+(1|cyl), data = mtcars)
{dwplot(m2)} %>% 
    add_brackets(list(c("G1", "wt", "wt"), c("G2", "disp", "disp")))

# Error: `by` can't contain join column `group` which is missing from LHS

dev.off()

# Now get rid of the group column created by tidying lmer models
{dwplot(tidy(m2) %>% select(-group))} %>% 
    add_brackets(list(c("G1", "wt", "wt"), c("G2", "disp", "disp")))

# Looks good again
sammo3182 commented 3 years ago

The issue should have been fixed in the dev version.

image