strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
603 stars 91 forks source link

Error in plot_model(ri.nr) : "Error in rand.ef[[lcnt]] : subscript out of bounds" #836

Closed AntMath closed 2 years ago

AntMath commented 2 years ago

When plotting random effects from a merMod object with plot_model, an error pops up if 1 is not included in the ri.nr numerical vector.

See example below:

library(lme4)
data("iris")
fit = lmer(Sepal.Length~Species + (1|Sepal.Width) + (1|Petal.Length),data=iris)

# 1 is there, no issue
plot_model(fit, type = "re", ri.nr = c(1,2))

# 1 is absent: "Error in rand.ef[[lcnt]] : subscript out of bounds
plot_model(fit, type = "re", ri.nr = 2)
strengejacke commented 2 years ago

Thanks, should be fixed in the latest commit. Try devtools::install_github("strengejacke/sjPlot"). If you encounter any issues, let me know!