diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index c28a589..ab191f1 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -5,10 +5,12 @@ on: branches: - main - master + - dev pull_request: branches: - main - master + - dev name: R-CMD-check diff --git a/DESCRIPTION b/DESCRIPTION index 72429e5..0c32d09 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,7 @@ Authors@R: role = c("aut", "cre"), email = "packages@jaredlander.com", comment = c(ORCID = "0000-0002-7291-726X")) -Version: 1.2.9 +Version: 1.3.1 Date: 2025-08-23 Description: Plots the coefficients from model objects. This very quickly shows the user the point estimates and confidence intervals for fitted models. License: BSD_3_clause + file LICENSE @@ -39,3 +39,5 @@ Suggests: rmarkdown Encoding: UTF-8 RoxygenNote: 7.3.2 +Enhances: + hardhat diff --git a/NEWS.md b/NEWS.md index 6042b28..bc58a50 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# Version 1.3.1 +- Added support for tidymodels workflows + +# Version 1.2.9 +- Bug Fixes + # Version 1.2.8 - Methods for plotting `{workflows}` and `{parsnip}` models. - Fixed warning due to deprecation of `guide` argument in `{ggplot2}`. diff --git a/R/coefplot.r b/R/coefplot.r index fd78d31..98e4de5 100644 --- a/R/coefplot.r +++ b/R/coefplot.r @@ -338,6 +338,20 @@ coefplot.model_fit <- function(model, ...) coefplot.default(model$fit, ...) } +#' @title coefplot.workflow +#' @description Coefplot method for workflow objects +#' @details Pulls model element out of workflow object then calls \code{coefplot}. +#' @export +# @author Jared P. Lander +#' @describeIn coefplot \code{workflow} +#' @param model A workflow object +#' @param \dots All arguments are passed on to \code{\link{coefplot}}. Please see that function for argument information. +#' +coefplot.model_fit <- function(model, ...) +{ + coefplot(hardhat::extract_fit_engine(model), ...) +} + #' coefplot.rxGlm #' # Dotplot for rxGlm coefficients diff --git a/cran-comments.md b/cran-comments.md index 6687f3b..e78d4d6 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,6 @@ ## Version Number -1.2.9 +1.3.1 ## Test environments @@ -13,7 +13,7 @@ - ubuntu-22.04 (devel) - ubuntu-24.04 (release) - ubuntu-24.04 (devel) -- Ubuntu 12.04, R 4.5.1 +- Ubuntu 22.04, R 4.5.1 ## R CMD check results diff --git a/man/coefplot.Rd b/man/coefplot.Rd index 70a3588..debc583 100644 --- a/man/coefplot.Rd +++ b/man/coefplot.Rd @@ -64,6 +64,8 @@ coefplot(model, ...) \method{coefplot}{model_fit}(model, ...) +\method{coefplot}{model_fit}(model, ...) + \method{coefplot}{rxGlm}(...) \method{coefplot}{rxLinMod}(...) @@ -71,7 +73,7 @@ coefplot(model, ...) \method{coefplot}{rxLogit}(...) } \arguments{ -\item{model}{A parsnip object} +\item{model}{A workflow object} \item{\dots}{All arguments are passed on to \code{\link{coefplot.lm}}. Please see that function for argument information.} @@ -173,6 +175,8 @@ Dotplot for glm coefficients Coefplot method for workflow objects Coefplot method for parsnip objects + +Coefplot method for workflow objects } \details{ A graphical display of the coefficients and standard errors from a fitted glm model @@ -184,6 +188,8 @@ For more information on this function and it's arguments see \code{\link{coefplo Pulls model element out of workflow object then calls \code{coefplot}. Pulls model element out of parsnip object then calls \code{coefplot}. + +Pulls model element out of workflow object then calls \code{coefplot}. } \section{Methods (by class)}{ \itemize{ @@ -197,6 +203,8 @@ Pulls model element out of parsnip object then calls \code{coefplot}. \item \code{coefplot(model_fit)}: \code{parsnip} +\item \code{coefplot(model_fit)}: \code{workflow} + \item \code{coefplot(rxGlm)}: \code{rxGlm} \item \code{coefplot(rxLinMod)}: \code{rxLinMod} diff --git a/tests/testthat/test-tidymodels.R b/tests/testthat/test-tidymodels.R index 4a03012..b1a8f53 100644 --- a/tests/testthat/test-tidymodels.R +++ b/tests/testthat/test-tidymodels.R @@ -8,6 +8,8 @@ flow <- workflow() %>% mod5 <- parsnip::fit(flow, data=mtcars) mod6 <- parsnip::fit(lm_spec, mpg ~ cyl + qsec + disp, data=mtcars) +mod7 <- workflows::fit(flow, data=mtcars) + coef5_static_default <- coefplot(mod5) coef5_static_false <- coefplot(mod5, interactive=FALSE) coef5_interactive <- coefplot(mod5, interactive=TRUE) @@ -18,12 +20,20 @@ coef6_static_false <- coefplot(mod6, interactive=FALSE) coef6_interactive <- coefplot(mod6, interactive=TRUE) coef6_interactive_sorted <- coefplot(mod6, interactive=TRUE, sort='magnitude') +coef7_static_default <- coefplot(mod7) +coef7_static_false <- coefplot(mod7, interactive=FALSE) +coef7_interactive <- coefplot(mod7, interactive=TRUE) +coef7_interactive_sorted <- coefplot(mod7, interactive=TRUE, sort='magnitude') + test_that("Static plots return ggplot objects", { expect_s3_class(coef5_static_default, 'ggplot') expect_s3_class(coef5_static_false, 'ggplot') expect_s3_class(coef6_static_default, 'ggplot') expect_s3_class(coef6_static_false, 'ggplot') + + expect_s3_class(coef7_static_default, 'ggplot') + expect_s3_class(coef7_static_false, 'ggplot') }) test_that("Interactive plots return plotly objects", { @@ -32,4 +42,7 @@ test_that("Interactive plots return plotly objects", { expect_s3_class(coef6_interactive, 'plotly') expect_s3_class(coef6_interactive_sorted, 'plotly') + + expect_s3_class(coef7_interactive, 'plotly') + expect_s3_class(coef7_interactive_sorted, 'plotly') })