From c77ac5fd55fffae213433ca9a9bdb844b643b1bc Mon Sep 17 00:00:00 2001 From: svmiller Date: Thu, 22 Aug 2024 16:22:59 +0200 Subject: [PATCH] update --- DESCRIPTION | 2 +- R/linloess_plot.R | 21 +++++++++++++-------- cran-comments.md | 4 +--- man/linloess_plot.Rd | 18 ++++++++++++++++-- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f4463d1..ad4cac4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: stevemisc Type: Package Title: Steve's Miscellaneous Functions -Version: 1.7.9 +Version: 1.8.0 Depends: R (>= 3.6.0), stats Authors@R: c( person("Steve", "Miller", email = "steven.v.miller@gmail.com", diff --git a/R/linloess_plot.R b/R/linloess_plot.R index 5f07951..0ee8a00 100644 --- a/R/linloess_plot.R +++ b/R/linloess_plot.R @@ -28,12 +28,17 @@ #' @author Steven V. Miller #' #' @param mod a fitted OLS model -#' @param resid logical, defaults to \code{FALSE}. If \code{FALSE}, the y-axis +#' @param resid logical, defaults to \code{TRUE}. If \code{FALSE}, the y-axis #' on these plots are the raw values of the dependent variable. If \code{TRUE}, #' the y-axis is the model's residuals. Either work well here for the matter #' at hand, provided you treat the output here as illustrative or suggestive. #' @param se logical, defaults to \code{TRUE}. If \code{TRUE}, gives standard #' error estimates with the assorted smoothers. +#' @param span a numeric, defaults to .75. An adjustment to the smoother. Higher +#' values permit smoother lines and might be warranted in the presence of +#' sparse pockets of the data. +#' @param smoother defaults to "loess", and is passed to the 'method' argument +#' for the non-linear smoother. #' @param ... optional parameters, passed to the scatterplot #' (\code{geom_point()}) component of this function. Useful if you want to make #' the smoothers more legible against the points. @@ -46,7 +51,7 @@ #' linloess_plot(M1, color="black", pch=21) -linloess_plot <- function(mod, resid = FALSE, se = TRUE, ...) { +linloess_plot <- function(mod, resid = TRUE, smoother = "loess", se = TRUE, span = .75, ...) { modframe <- model.frame(mod) if(resid == FALSE) { @@ -62,9 +67,9 @@ linloess_plot <- function(mod, resid = FALSE, se = TRUE, ...) { geom_point(...) + # linear smoother geom_smooth(method="lm", fill="blue", se = se) + - # loess smoother, with different color - geom_smooth(method="loess", color="black", linetype="dashed", - se = se) + # smoother, with different color + geom_smooth(method = smoother, color = "black", linetype = "dashed", + se = se, span = span) } else { modframe$.resid <- resid(mod) @@ -81,9 +86,9 @@ linloess_plot <- function(mod, resid = FALSE, se = TRUE, ...) { geom_point(...) + # linear smoother geom_smooth(method="lm", fill="blue", se = se) + - # loess smoother, with different color - geom_smooth(method="loess", color="black", linetype="dashed", - se = se) + # smoother, with different color + geom_smooth(method = smoother, color = "black", linetype = "dashed", + se = se, span = span) } diff --git a/cran-comments.md b/cran-comments.md index 1f356f4..8f8b416 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -8,8 +8,6 @@ R CMD check done via `devtools::check()`, resulting in 0 errors, 0 warnings and `devtools::spell_check()` results in a lot of typos, all of which are false positives. -This submission is accelerated by a recent email from CRAN about an error that comes up in the `ps_spells()` function. In particular, it comes with the use of `order()` on a data frame. I have since addressed that in this release. - ## Downstream dependencies -`{peacesciencer}`, a package I created and maintain, is a downstream dependency. This release actually does concern that package because that package was also flagged by CRAN for the same issue that is accelerating this release. However, the issue that affects that package is directly connected to this package because `{peacesciencer}` uses the `ps_spells()` function in this package. Adequately fixing the issue here will address the issue in `{peacesciencer}`, though it does mean fixing it here first takes precedence. +`{peacesciencer}`, a package I created and maintain, is a downstream dependency. That package is unaffected by this release. diff --git a/man/linloess_plot.Rd b/man/linloess_plot.Rd index 4432f24..7e5d96d 100644 --- a/man/linloess_plot.Rd +++ b/man/linloess_plot.Rd @@ -4,19 +4,33 @@ \alias{linloess_plot} \title{Compare Linear Smoother to LOESS Smoother for Your OLS Model} \usage{ -linloess_plot(mod, resid = FALSE, se = TRUE, ...) +linloess_plot( + mod, + resid = TRUE, + smoother = "loess", + se = TRUE, + span = 0.75, + ... +) } \arguments{ \item{mod}{a fitted OLS model} -\item{resid}{logical, defaults to \code{FALSE}. If \code{FALSE}, the y-axis +\item{resid}{logical, defaults to \code{TRUE}. If \code{FALSE}, the y-axis on these plots are the raw values of the dependent variable. If \code{TRUE}, the y-axis is the model's residuals. Either work well here for the matter at hand, provided you treat the output here as illustrative or suggestive.} +\item{smoother}{defaults to "loess", and is passed to the 'method' argument +for the non-linear smoother.} + \item{se}{logical, defaults to \code{TRUE}. If \code{TRUE}, gives standard error estimates with the assorted smoothers.} +\item{span}{a numeric, defaults to .75. An adjustment to the smoother. Higher +values permit smoother lines and might be warranted in the presence of +sparse pockets of the data.} + \item{...}{optional parameters, passed to the scatterplot (\code{geom_point()}) component of this function. Useful if you want to make the smoothers more legible against the points.}