From 1417e43ccfd5cc0a20aff9a07108b83500e279f6 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Mon, 16 Oct 2023 15:48:49 -0400 Subject: [PATCH] tidymodels bug --- DESCRIPTION | 2 +- R/methods_tidymodels.R | 3 ++- inst/tinytest/test-pkg-tidymodels.R | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b30f6be15..116de2c0e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: marginaleffects Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests -Version: 0.15.1.9014 +Version: 0.15.1.9015 Authors@R: c(person(given = "Vincent", family = "Arel-Bundock", diff --git a/R/methods_tidymodels.R b/R/methods_tidymodels.R index 1eb89256a..2129439a2 100644 --- a/R/methods_tidymodels.R +++ b/R/methods_tidymodels.R @@ -40,7 +40,8 @@ get_predict.model_fit <- function(model, newdata, type = NULL, ...) { out <- stats::predict(model, new_data = newdata, type = type) if (type == "numeric") { - out <- data.frame(rowid = seq_along(out), estimate = out[[".pred"]]) + v <- intersect(c(".pred", ".pred_res"), colnames(out))[1] + out <- data.frame(rowid = seq_along(out), estimate = out[[v]]) } else if (type == "class") { out <- data.frame(rowid = seq_along(out), estimate = out[[".pred_class"]]) diff --git a/inst/tinytest/test-pkg-tidymodels.R b/inst/tinytest/test-pkg-tidymodels.R index 8cda903dd..d0b06507f 100644 --- a/inst/tinytest/test-pkg-tidymodels.R +++ b/inst/tinytest/test-pkg-tidymodels.R @@ -39,7 +39,6 @@ p <- predictions(mod, newdata = bikes, type = "numeric") |> expect_inherits(p, "predictions") expect_true("std.error" %in% colnames(p)) -exit_file("test this") mfx <- avg_slopes(mod, newdata = bikes, type = "numeric") |> suppressWarnings() expect_inherits(mfx, "marginaleffects")