Skip to content

Commit 6325525

Browse files
authored
Merge pull request #30 from jaredlander/fix/aes_string
Fix/aes string
2 parents 8710ffb + 024b8cc commit 6325525

17 files changed

+5823
-592
lines changed
File renamed without changes.

.github/workflows/R-CMD-check.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,24 @@ jobs:
2626
- {os: macOS-latest, r: 'release'}
2727
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
2828
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
29+
- {os: ubuntu-22.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}
30+
- {os: ubuntu-22.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}
31+
- {os: ubuntu-24.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}
32+
- {os: ubuntu-24.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}
2933

3034
env:
3135
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
3236
RSPM: ${{ matrix.config.rspm }}
3337
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
3438

3539
steps:
36-
- uses: actions/checkout@v2
40+
- uses: actions/checkout@v4
3741

38-
- uses: r-lib/actions/setup-r@v1
42+
- uses: r-lib/actions/setup-r@v2
3943
with:
4044
r-version: ${{ matrix.config.r }}
4145

42-
- uses: r-lib/actions/setup-pandoc@v1
46+
- uses: r-lib/actions/setup-pandoc@v2
4347

4448
- name: Query dependencies
4549
run: |
@@ -50,7 +54,7 @@ jobs:
5054

5155
- name: Cache R packages
5256
if: runner.os != 'Windows'
53-
uses: actions/cache@v2
57+
uses: actions/cache@v4
5458
with:
5559
path: ${{ env.R_LIBS_USER }}
5660
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
@@ -78,7 +82,7 @@ jobs:
7882

7983
- name: Upload check results
8084
if: failure()
81-
uses: actions/upload-artifact@main
85+
uses: actions/upload-artifact@v4
8286
with:
8387
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
8488
path: check

DESCRIPTION

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ Authors@R:
77
role = c("aut", "cre"),
88
email = "packages@jaredlander.com",
99
comment = c(ORCID = "0000-0002-7291-726X"))
10-
Version: 1.2.8
11-
Date: 2022-01-12
12-
Maintainer: Jared P. Lander <packages@jaredlander.com>
10+
Version: 1.2.9
11+
Date: 2025-08-23
1312
Description: Plots the coefficients from model objects. This very quickly shows the user the point estimates and confidence intervals for fitted models.
1413
License: BSD_3_clause + file LICENSE
1514
LazyLoad: yes
@@ -27,7 +26,7 @@ Imports:
2726
purrr,
2827
plotly
2928
ByteCompile: TRUE
30-
Packaged: 2018-01-02 Jared
29+
Packaged: 2025-08-23 Jared
3130
Suggests:
3231
testthat (>= 2.0.0),
3332
covr,
@@ -39,4 +38,4 @@ Suggests:
3938
knitr,
4039
rmarkdown
4140
Encoding: UTF-8
42-
RoxygenNote: 7.1.2
41+
RoxygenNote: 7.3.2

NAMESPACE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ S3method(coefplot,data.frame)
77
S3method(coefplot,default)
88
S3method(coefplot,glm)
99
S3method(coefplot,lm)
10+
S3method(coefplot,model_fit)
1011
S3method(coefplot,rxGlm)
1112
S3method(coefplot,rxLinMod)
1213
S3method(coefplot,rxLogit)
14+
S3method(coefplot,workflow)
1315
S3method(extract.coef,cv.glmnet)
16+
S3method(extract.coef,default)
17+
S3method(extract.coef,glm)
18+
S3method(extract.coef,glmnet)
19+
S3method(extract.coef,lm)
1420
S3method(extract.coef,maxLik)
21+
S3method(extract.coef,rxGlm)
22+
S3method(extract.coef,rxLinMod)
23+
S3method(extract.coef,rxLogit)
1524
S3method(extract.coef,xgb.Booster)
1625
S3method(extractPath,cv.glmnet)
1726
S3method(extractPath,glmnet)

R/buildPlot.r

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ buildPlotting.default <- function(
8282

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

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

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

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

112112
# for a regular coefplot or a multiplot in seperate facets
113-
#p <- ggplot(data=modelCI, aes_string(x=value))
114-
p <- ggplot(data=modelCI, aes_string(x=value, y=coefficient)) # the basics of the plot
113+
#p <- ggplot(data=modelCI, aes(x=.data[[value]]))
114+
p <- ggplot(data=modelCI, aes(x=.data[[value]], y=.data[[coefficient]])) # the basics of the plot
115115
#p <- p + colorAes[[1 + multi]] # # in case model needs to be factorized, do it here
116116
p <- p + geom_vline(xintercept=0, colour=zeroColor, linetype=zeroType, lwd=zeroLWD) # the zero line
117117
p <- p + outerCIGeom + # the outer CI bars

R/coefplot-package.r

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
#' @keywords internal
2+
"_PACKAGE"
13
#' Plotting Model Coefficients
2-
#'
3-
#' Provides an S3 generic method for plotting coefficients from a model so it can be extended to other model types.
4-
#'
5-
#' Currently, methods are available for lm, glm and rxLinMod objects.
6-
#'
7-
# @import plyr ggplot2 reshape2
8-
#' @docType package
4+
#' @description
5+
#' A short description...
6+
#' Provides an S3 generic method for plotting coefficients from a model so it can be extended to other model types.
97
#' @name coefplot
10-
#' @aliases coefplot-package
8+
# @aliases coefplot-package
9+
10+
# @import plyr ggplot2 reshape2
1111
NULL
1212

1313

R/coefplot.r

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ coefplot <- function(model, ...)
9999
#' @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.
100100
#' @param interactive If \code{TRUE} an interactive plot is generated instead of \code{ggplot2}
101101
#' @param \dots Arguments passed on to other functions
102-
#' @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.
103-
#' @seealso \code{\link{lm}} \code{\link{glm}} \code{\link{ggplot}} \code{\link{coefplot}} \code{\link{plotcoef}}
102+
#' @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.
103+
#' @seealso \code{\link{lm}} \code{\link[stats]{glm}} \code{\link[ggplot2]{ggplot}} \code{\link{coefplot}} \code{\link{plotcoef}}
104104
#' @export coefplot.default
105105
#' @export
106106
#' @describeIn coefplot Default method
@@ -283,9 +283,9 @@ coefplot.lm <- function(...)
283283

284284
#' coefplot.glm
285285
#'
286-
# Dotplot for glm coefficients
286+
#' Dotplot for glm coefficients
287287
#'
288-
# A graphical display of the coefficients and standard errors from a fitted glm model
288+
#' A graphical display of the coefficients and standard errors from a fitted glm model
289289
#'
290290
# \code{\link{coefplot}} is the S3 generic method for plotting the coefficients from a fitted model.
291291
#'
@@ -314,6 +314,7 @@ coefplot.glm <- function(...)
314314
#' @title coefplot.workflow
315315
#' @description Coefplot method for workflow objects
316316
#' @details Pulls model element out of workflow object then calls \code{coefplot}.
317+
#' @export
317318
# @author Jared P. Lander
318319
#' @describeIn coefplot \code{tidymodels workflows}
319320
#' @param model A workflow object
@@ -326,6 +327,7 @@ coefplot.workflow <- function(model, ...)
326327
#' @title coefplot.model_fit
327328
#' @description Coefplot method for parsnip objects
328329
#' @details Pulls model element out of parsnip object then calls \code{coefplot}.
330+
#' @export
329331
# @author Jared P. Lander
330332
#' @describeIn coefplot \code{parsnip}
331333
#' @param model A parsnip object

R/extractCoef.r

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#'
88
#' @author Jared P. Lander
99
#' @method extract.coef default
10+
#' @export
1011
#' @aliases extract.coef.default
1112
#' @param model Model object to extract information from.
1213
#' @param \dots Further arguments
@@ -45,6 +46,7 @@ extract.coef.default <- function(model, ...)
4546
#' @author Jared P. Lander
4647
#' @aliases extract.coef.lm
4748
#' @method extract.coef lm
49+
#' @export
4850
#' @inheritParams extract.coef.default
4951
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
5052
#' error and the variable name.
@@ -73,6 +75,7 @@ extract.coef.lm <- function(model, ...)
7375
#' @aliases extract.coef.glm
7476
#' @inheritParams extract.coef.default
7577
#' @method extract.coef glm
78+
#' @export
7679
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
7780
#' error and the variable name.
7881
#' @examples
@@ -136,6 +139,7 @@ extract.coef <- function(model, ...)
136139
#' @aliases extract.coef.rxLinMod
137140
#' @inheritParams extract.coef.default
138141
#' @method extract.coef rxLinMod
142+
#' @export
139143
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
140144
#' error and the variable name.
141145
#' @examples
@@ -172,6 +176,7 @@ extract.coef.rxLinMod <- function(model, ...)
172176
#' @aliases extract.coef.rxGlm
173177
#' @inheritParams extract.coef.default
174178
#' @method extract.coef rxGlm
179+
#' @export
175180
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
176181
#' error and the variable name.
177182
#' @examples
@@ -201,6 +206,7 @@ extract.coef.rxGlm <- function(model, ...)
201206
#' @aliases extract.coef.rxLogit
202207
#' @inheritParams extract.coef.default
203208
#' @method extract.coef rxLogit
209+
#' @export
204210
#' @return A \code{\link{data.frame}} containing the coefficient, the standard
205211
#' error and the variable name.
206212
#' @examples
@@ -216,12 +222,30 @@ extract.coef.rxLogit <- function(model, ...)
216222
extract.coef.default(model=model, ...)
217223
}
218224

225+
# #' @title extract.coef.glmnet
226+
# #' @description Extract Coefficient Information from Models
227+
# #' @details Gets the coefficient values and variable names from a model. Since
228+
# #' glmnet does not have standard errors, those will just be NA.
229+
# #' @author Jared P. Lander
230+
# #' @method extract.coef glmnet
231+
# #' @aliases extract.coef.elnet
232+
# #' @param model Model object from which to extract information.
233+
# #' @param lambda Value of penalty parameter
234+
# #' @param \dots Further arguments
235+
# #' @return A \code{\link{data.frame}} containing the coefficient, the standard
236+
# #' error and the variable name.
237+
# extract.coef.elnet <- function(model, lambda=stats::median(model$lambda), ...)
238+
# {
239+
# extract.coef.glmnet(model, lambda, ...)
240+
# }
241+
219242
#' @title extract.coef.glmnet
220243
#' @description Extract Coefficient Information from Models
221244
#' @details Gets the coefficient values and variable names from a model. Since
222245
#' glmnet does not have standard errors, those will just be NA.
223246
#' @author Jared P. Lander
224247
#' @method extract.coef glmnet
248+
#' @export
225249
#' @aliases extract.coef.glmnet
226250
#' @param model Model object from which to extract information.
227251
#' @param lambda Value of penalty parameter
@@ -233,12 +257,12 @@ extract.coef.rxLogit <- function(model, ...)
233257
#' library(glmnet)
234258
#' library(ggplot2)
235259
#' library(useful)
260+
#' library(coefplot)
236261
#' data(diamonds)
237262
#' diaX <- build.x(price ~ carat + cut + x - 1, data=diamonds, contrasts = TRUE)
238263
#' diaY <- build.y(price ~ carat + cut + x - 1, data=diamonds)
239264
#' modG1 <- glmnet(x=diaX, y=diaY)
240265
#' extract.coef(modG1)
241-
#' }
242266
#' \dontshow{\}}
243267
#'
244268
extract.coef.glmnet <- function(model, lambda=stats::median(model$lambda), ...)
@@ -317,7 +341,6 @@ extract.coef.cv.glmnet <- function(model, lambda="lambda.min", ...)
317341
#' N <- length(x)
318342
#' res <- maxLik(loglik, start=c(0,1)) # use 'wrong' start values
319343
#' extract.coef(res)
320-
#' }
321344
#' \dontshow{
322345
#' \}
323346
#' }

R/position.r

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ pos_dodgev <- function(df, height) {
112112

113113
#' Adjust position by dodging overlaps to the side.
114114
#'
115-
#' @inheritParams ggplot2::position_identity
116115
#' @param height Dodging height, when different to the height of the individual
117116
#' elements. This is useful when you want to align narrow geoms with wider
118117
#' geoms. See the examples for a use case.

cran-comments.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Version Number
22

3-
1.2.8
3+
1.2.9
44

55
## Test environments
66

@@ -9,20 +9,15 @@
99
- macOS-latest (release)
1010
- ubuntu-20.04 (release)
1111
- ubuntu-20.04 (devel)
12-
- Windows 10, R 4.1.0
13-
- Ubuntu 18.04, R 4.1.2
14-
- Win-Builder
15-
- R-Hub
12+
- ubuntu-22.04 (release)
13+
- ubuntu-22.04 (devel)
14+
- ubuntu-24.04 (release)
15+
- ubuntu-24.04 (devel)
16+
- Ubuntu 12.04, R 4.5.1
1617

1718
## R CMD check results
1819

19-
There were no ERRORs, WARNINGs, NOTEs when checked locally on Windows and Ubuntu or the GitHub Actions for Windows or Ubuntu-release.
20-
21-
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.
22-
23-
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.
24-
25-
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.
20+
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.
2621

2722
## Tests
2823

0 commit comments

Comments
 (0)