Skip to content

Commit

Permalink
simplify grab_residuals
Browse files Browse the repository at this point in the history
  • Loading branch information
dajmcdon committed Nov 29, 2023
1 parent 378577a commit 6576454
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions R/layer_residual_quantiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,10 @@ slather.layer_residual_quantiles <-

grab_residuals <- function(the_fit, components) {
if (the_fit$spec$mode != "regression") {
rlang::abort("For meaningful residuals, the predictor should be a regression model.")
cli::cli_abort("For meaningful residuals, the predictor should be a regression model.")
}
r_generic <- attr(utils::methods(class = class(the_fit$fit)[1]), "info")$generic
if ("residuals" %in% r_generic) { # Try to use the available method.
cl <- class(the_fit$fit)[1]
r <- residuals(the_fit$fit)
r <- stats::residuals(the_fit$fit)
if (!is.null(r)) { # Got something from the method
if (inherits(r, "data.frame")) {
if (".resid" %in% names(r)) { # success
return(r)
Expand Down

0 comments on commit 6576454

Please sign in to comment.