Skip to content

Commit

Permalink
moved the glmmTMB require statement in plot_type_ranef to _after_ the…
Browse files Browse the repository at this point in the history
… model class check
  • Loading branch information
jvparidon committed Oct 28, 2022
1 parent 652eb9b commit a22d489
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions R/plot_type_ranef.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,23 @@ plot_type_ranef <- function(model,
if (!requireNamespace("lme4", quietly = TRUE)) {
stop("Package 'lme4' required for this function to work, please install it.")
}
if (!requireNamespace("glmmTMB", quietly = TRUE)) {
stop("Package 'glmmTMB' required for this function to work, please install it.")
}

# get tidy output of summary ----

if (inherits(model, "glmmTMB"))
if (inherits(model, "glmmTMB")) {
if (!requireNamespace("glmmTMB", quietly = TRUE)) {
stop("Package 'glmmTMB' required for this function to work, please install it.")
}
rand.ef <- glmmTMB::ranef(model)[[1]]
else if (inherits(model, "MixMod")) {
} else {
rand.ef <- lme4::ranef(model)
if (!is.list(rand.ef)) {
rand.ef <- list(rand.ef)
names(rand.ef) <- insight::find_random(model, flatten = TRUE)
if (inherits(model, "MixMod")) {
if (!is.list(rand.ef)) {
rand.ef <- list(rand.ef)
names(rand.ef) <- insight::find_random(model, flatten = TRUE)
}
}
} else
rand.ef <- lme4::ranef(model)
}


if (inherits(model, "clmm"))
Expand Down

0 comments on commit a22d489

Please sign in to comment.