From 0caa7b9448c25be9f87f33d065ad956e4bae6881 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 20 Jul 2024 18:19:03 +0200 Subject: [PATCH] Bug: `pretty_names = "labels"` does not work for `AER::tobit` models Fixes #987 --- R/format_parameters.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/format_parameters.R b/R/format_parameters.R index 818556416..dbbc5a19b 100644 --- a/R/format_parameters.R +++ b/R/format_parameters.R @@ -378,6 +378,12 @@ format_parameters.parameters_model <- function(model, ...) { if (!is.null(model) && insight::is_regression_model(model) && !is.data.frame(model)) { # get data, but exclude response - we have no need for that label mf <- insight::get_data(model, source = "mf", verbose = FALSE) + # sanity check - any labels? + has_labels <- vapply(mf, function(i) !is.null(attr(i, "labels", exact = TRUE)), logical(1)) + # if we don't have labels, we try to get data from environment + if (!any(has_labels)) { + mf <- insight::get_data(model, source = "environment", verbose = FALSE) + } resp <- insight::find_response(model, combine = FALSE) mf <- mf[, setdiff(colnames(mf), resp), drop = FALSE]