Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidymodels in find_response() #1014

Merged
merged 2 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: insight
Title: Easy Access to Model Information for Various Model Objects
Version: 1.0.2.11
Version: 1.0.2.12
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -205,6 +205,7 @@ Suggests:
tinytable (>= 0.1.0),
TMB,
truncreg,
tune,
tweedie,
VGAM,
WeightIt,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ S3method(find_response,mediate)
S3method(find_response,mjoint)
S3method(find_response,model_fit)
S3method(find_response,selection)
S3method(find_response,tune_results)
S3method(find_response,workflow)
S3method(find_statistic,default)
S3method(find_terms,afex_aov)
S3method(find_terms,aovlist)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* `format_table()` gets a `select` argument, which can be used to select columns
and column layout in a glue-like style.

* `find_response()` now also works for _tidymodels_ workflows.

# insight 1.0.2

## Changes
Expand Down
20 changes: 20 additions & 0 deletions R/find_response.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@
}


#' @export
find_response.tune_results <- function(x, combine = TRUE, ...) {
att <- attributes(x)
if (any(names(att) == "outcomes")) {

Check warning on line 130 in R/find_response.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/find_response.R,line=130,col=3,[unnecessary_nesting_linter] Reduce the nesting of this if/else statement by unnesting the portion without an exit clause (i.e., stop(), return(), abort(), quit(), q()).
resp <- att$outcomes
} else {
return(NULL)
}
check_cbind(resp, combine, model = x)
}


#' @export
find_response.workflow <- function(x, combine = TRUE, ...) {
insight::check_if_installed("tune")
resp <- tune::outcome_names(x)
check_cbind(resp, combine, model = x)
}


#' @rdname find_response
#' @export
find_response.mjoint <- function(x, combine = TRUE, component = c("conditional", "survival", "all"), ...) {
Expand Down
Loading