Skip to content
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
File renamed without changes.
14 changes: 9 additions & 5 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,24 @@ jobs:
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-22.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}
- {os: ubuntu-22.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}
- {os: ubuntu-24.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}
- {os: ubuntu-24.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
run: |
Expand All @@ -50,7 +54,7 @@ jobs:

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
Expand Down Expand Up @@ -78,7 +82,7 @@ jobs:

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
9 changes: 4 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ Authors@R:
role = c("aut", "cre"),
email = "packages@jaredlander.com",
comment = c(ORCID = "0000-0002-7291-726X"))
Version: 1.2.8
Date: 2022-01-12
Maintainer: Jared P. Lander <packages@jaredlander.com>
Version: 1.2.9
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
LazyLoad: yes
Expand All @@ -27,7 +26,7 @@ Imports:
purrr,
plotly
ByteCompile: TRUE
Packaged: 2018-01-02 Jared
Packaged: 2025-08-23 Jared
Suggests:
testthat (>= 2.0.0),
covr,
Expand All @@ -39,4 +38,4 @@ Suggests:
knitr,
rmarkdown
Encoding: UTF-8
RoxygenNote: 7.1.2
RoxygenNote: 7.3.2
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ S3method(coefplot,data.frame)
S3method(coefplot,default)
S3method(coefplot,glm)
S3method(coefplot,lm)
S3method(coefplot,model_fit)
S3method(coefplot,rxGlm)
S3method(coefplot,rxLinMod)
S3method(coefplot,rxLogit)
S3method(coefplot,workflow)
S3method(extract.coef,cv.glmnet)
S3method(extract.coef,default)
S3method(extract.coef,glm)
S3method(extract.coef,glmnet)
S3method(extract.coef,lm)
S3method(extract.coef,maxLik)
S3method(extract.coef,rxGlm)
S3method(extract.coef,rxLinMod)
S3method(extract.coef,rxLogit)
S3method(extract.coef,xgb.Booster)
S3method(extractPath,cv.glmnet)
S3method(extractPath,glmnet)
Expand Down
10 changes: 5 additions & 5 deletions R/buildPlot.r
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ buildPlotting.default <- function(

## build the layer infos
outerCIGeom <- geom_errorbarh(
aes_string(xmin="LowOuter", xmax="HighOuter", color="Model", linetype="Model"),
aes(xmin=.data[["LowOuter"]], xmax=.data[["HighOuter"]], color=.data[["Model"]], linetype=.data[["Model"]]),
lwd=lwdOuter, height=errorHeight, position=position_dodgev(height=dodgeHeight),
na.rm=TRUE
)

innerCIGeom <- geom_errorbarh(
aes_string(xmin="LowInner", xmax="HighInner", color="Model", linetype="Model"),
aes(xmin=.data[["LowInner"]], xmax=.data[["HighInner"]], color=.data[["Model"]], linetype=.data[["Model"]]),
lwd=lwdInner, height=errorHeight, position=position_dodgev(height=dodgeHeight),
na.rm=TRUE
)
Expand All @@ -97,7 +97,7 @@ buildPlotting.default <- function(
#ribbonGeom <- list(None=NULL, geom_ribbon(aes(ymin=LowOuter, ymax=HighOuter, group=Checkers), data=modelCI, fill=fillColor, alpha=alpha, lwd=lwdOuter))

# point layer
pointGeom <- geom_point(aes_string(x=value, color="Model", shape="Model"), size=pointSize, position=position_dodgev(height=dodgeHeight))
pointGeom <- geom_point(aes(x=.data[[value]], color=.data[["Model"]], shape=.data[["Model"]]), size=pointSize, position=position_dodgev(height=dodgeHeight))

#colorAes <- list(None=NULL, Single=aes(color=as.factor(Model)))
colorScaleSingle <- scale_color_manual(values=rep(color, length(unique(modelCI$Model))), guide='none')
Expand All @@ -110,8 +110,8 @@ buildPlotting.default <- function(
faceting <- list(None=NULL, Display=facet_wrap(~Checkers, scales=scales))

# for a regular coefplot or a multiplot in seperate facets
#p <- ggplot(data=modelCI, aes_string(x=value))
p <- ggplot(data=modelCI, aes_string(x=value, y=coefficient)) # the basics of the plot
#p <- ggplot(data=modelCI, aes(x=.data[[value]]))
p <- ggplot(data=modelCI, aes(x=.data[[value]], y=.data[[coefficient]])) # the basics of the plot
#p <- p + colorAes[[1 + multi]] # # in case model needs to be factorized, do it here
p <- p + geom_vline(xintercept=0, colour=zeroColor, linetype=zeroType, lwd=zeroLWD) # the zero line
p <- p + outerCIGeom + # the outer CI bars
Expand Down
16 changes: 8 additions & 8 deletions R/coefplot-package.r
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#' @keywords internal
"_PACKAGE"
#' Plotting Model Coefficients
#'
#' Provides an S3 generic method for plotting coefficients from a model so it can be extended to other model types.
#'
#' Currently, methods are available for lm, glm and rxLinMod objects.
#'
# @import plyr ggplot2 reshape2
#' @docType package
#' @description
#' A short description...
#' Provides an S3 generic method for plotting coefficients from a model so it can be extended to other model types.
#' @name coefplot
#' @aliases coefplot-package
# @aliases coefplot-package

# @import plyr ggplot2 reshape2
NULL


Expand Down
10 changes: 6 additions & 4 deletions R/coefplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ coefplot <- function(model, ...)
#' @param shorten logical or character; If \code{FALSE} then coefficients for factor levels will include their variable name. If \code{TRUE} coefficients for factor levels will be stripped of their variable names. If a character vector of variables only coefficients for factor levels associated with those variables will the variable names stripped. Currently not available.
#' @param interactive If \code{TRUE} an interactive plot is generated instead of \code{ggplot2}
#' @param \dots Arguments passed on to other functions
#' @return If \code{plot} is \code{TRUE} then a \code{\link{ggplot}} object is returned. Otherwise a \code{\link{data.frame}} listing coefficients and confidence bands is returned.
#' @seealso \code{\link{lm}} \code{\link{glm}} \code{\link{ggplot}} \code{\link{coefplot}} \code{\link{plotcoef}}
#' @return If \code{plot} is \code{TRUE} then a \code{\link[ggplot2]{ggplot}} object is returned. Otherwise a \code{\link{data.frame}} listing coefficients and confidence bands is returned.
#' @seealso \code{\link{lm}} \code{\link[stats]{glm}} \code{\link[ggplot2]{ggplot}} \code{\link{coefplot}} \code{\link{plotcoef}}
#' @export coefplot.default
#' @export
#' @describeIn coefplot Default method
Expand Down Expand Up @@ -283,9 +283,9 @@ coefplot.lm <- function(...)

#' coefplot.glm
#'
# Dotplot for glm coefficients
#' Dotplot for glm coefficients
#'
# A graphical display of the coefficients and standard errors from a fitted glm model
#' A graphical display of the coefficients and standard errors from a fitted glm model
#'
# \code{\link{coefplot}} is the S3 generic method for plotting the coefficients from a fitted model.
#'
Expand Down Expand Up @@ -314,6 +314,7 @@ coefplot.glm <- function(...)
#' @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{tidymodels workflows}
#' @param model A workflow object
Expand All @@ -326,6 +327,7 @@ coefplot.workflow <- function(model, ...)
#' @title coefplot.model_fit
#' @description Coefplot method for parsnip objects
#' @details Pulls model element out of parsnip object then calls \code{coefplot}.
#' @export
# @author Jared P. Lander
#' @describeIn coefplot \code{parsnip}
#' @param model A parsnip object
Expand Down
27 changes: 25 additions & 2 deletions R/extractCoef.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#'
#' @author Jared P. Lander
#' @method extract.coef default
#' @export
#' @aliases extract.coef.default
#' @param model Model object to extract information from.
#' @param \dots Further arguments
Expand Down Expand Up @@ -45,6 +46,7 @@ extract.coef.default <- function(model, ...)
#' @author Jared P. Lander
#' @aliases extract.coef.lm
#' @method extract.coef lm
#' @export
#' @inheritParams extract.coef.default
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
#' error and the variable name.
Expand Down Expand Up @@ -73,6 +75,7 @@ extract.coef.lm <- function(model, ...)
#' @aliases extract.coef.glm
#' @inheritParams extract.coef.default
#' @method extract.coef glm
#' @export
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
#' error and the variable name.
#' @examples
Expand Down Expand Up @@ -136,6 +139,7 @@ extract.coef <- function(model, ...)
#' @aliases extract.coef.rxLinMod
#' @inheritParams extract.coef.default
#' @method extract.coef rxLinMod
#' @export
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
#' error and the variable name.
#' @examples
Expand Down Expand Up @@ -172,6 +176,7 @@ extract.coef.rxLinMod <- function(model, ...)
#' @aliases extract.coef.rxGlm
#' @inheritParams extract.coef.default
#' @method extract.coef rxGlm
#' @export
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
#' error and the variable name.
#' @examples
Expand Down Expand Up @@ -201,6 +206,7 @@ extract.coef.rxGlm <- function(model, ...)
#' @aliases extract.coef.rxLogit
#' @inheritParams extract.coef.default
#' @method extract.coef rxLogit
#' @export
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
#' error and the variable name.
#' @examples
Expand All @@ -216,12 +222,30 @@ extract.coef.rxLogit <- function(model, ...)
extract.coef.default(model=model, ...)
}

# #' @title extract.coef.glmnet
# #' @description Extract Coefficient Information from Models
# #' @details Gets the coefficient values and variable names from a model. Since
# #' glmnet does not have standard errors, those will just be NA.
# #' @author Jared P. Lander
# #' @method extract.coef glmnet
# #' @aliases extract.coef.elnet
# #' @param model Model object from which to extract information.
# #' @param lambda Value of penalty parameter
# #' @param \dots Further arguments
# #' @return A \code{\link{data.frame}} containing the coefficient, the standard
# #' error and the variable name.
# extract.coef.elnet <- function(model, lambda=stats::median(model$lambda), ...)
# {
# extract.coef.glmnet(model, lambda, ...)
# }

#' @title extract.coef.glmnet
#' @description Extract Coefficient Information from Models
#' @details Gets the coefficient values and variable names from a model. Since
#' glmnet does not have standard errors, those will just be NA.
#' @author Jared P. Lander
#' @method extract.coef glmnet
#' @export
#' @aliases extract.coef.glmnet
#' @param model Model object from which to extract information.
#' @param lambda Value of penalty parameter
Expand All @@ -233,12 +257,12 @@ extract.coef.rxLogit <- function(model, ...)
#' library(glmnet)
#' library(ggplot2)
#' library(useful)
#' library(coefplot)
#' data(diamonds)
#' diaX <- build.x(price ~ carat + cut + x - 1, data=diamonds, contrasts = TRUE)
#' diaY <- build.y(price ~ carat + cut + x - 1, data=diamonds)
#' modG1 <- glmnet(x=diaX, y=diaY)
#' extract.coef(modG1)
#' }
#' \dontshow{\}}
#'
extract.coef.glmnet <- function(model, lambda=stats::median(model$lambda), ...)
Expand Down Expand Up @@ -317,7 +341,6 @@ extract.coef.cv.glmnet <- function(model, lambda="lambda.min", ...)
#' N <- length(x)
#' res <- maxLik(loglik, start=c(0,1)) # use 'wrong' start values
#' extract.coef(res)
#' }
#' \dontshow{
#' \}
#' }
Expand Down
1 change: 0 additions & 1 deletion R/position.r
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ pos_dodgev <- function(df, height) {

#' Adjust position by dodging overlaps to the side.
#'
#' @inheritParams ggplot2::position_identity
#' @param height Dodging height, when different to the height of the individual
#' elements. This is useful when you want to align narrow geoms with wider
#' geoms. See the examples for a use case.
Expand Down
19 changes: 7 additions & 12 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Version Number

1.2.8
1.2.9

## Test environments

Expand All @@ -9,20 +9,15 @@
- macOS-latest (release)
- ubuntu-20.04 (release)
- ubuntu-20.04 (devel)
- Windows 10, R 4.1.0
- Ubuntu 18.04, R 4.1.2
- Win-Builder
- R-Hub
- ubuntu-22.04 (release)
- ubuntu-22.04 (devel)
- ubuntu-24.04 (release)
- ubuntu-24.04 (devel)
- Ubuntu 12.04, R 4.5.1

## R CMD check results

There were no ERRORs, WARNINGs, NOTEs when checked locally on Windows and Ubuntu or the GitHub Actions for Windows or Ubuntu-release.

GitHub Actions for Mac and Ubuntu-devel had a notes of an example taking more than 5 seconds, though I imagine that has more to do with the machine doing the testing.

WinBuild had a note of an example taking more than 10 seconds, though I imagine that has more to do with the machine doing the testing.

R-Hub had a note of an example taking more than 5 seconds, though I imagine that has more to do with the machine doing the testing.
There were no ERRORs, WARNINGs, NOTEs when checked locally on Ubuntu or the GitHub Actions for Windows or Mac. For Github Actions with Ubuntu-release there were no ERRORs or WARNINGs, just a NOTE, but that was related to the executiobn time of examples, likely due to using slow runners.

## Tests

Expand Down
14 changes: 14 additions & 0 deletions man/coefplot-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading