diff --git a/R/gg_utils.R b/R/gg_utils.R index 08ad2fd0..0bf8624d 100644 --- a/R/gg_utils.R +++ b/R/gg_utils.R @@ -535,6 +535,10 @@ gg_varname_extraction <- function(mapping_quo) { #' Measure of variability (`"sd"`, `"se"`, `"ci"`, `"iqr"`, or `"none"`). #' @param conf_level (`numeric`)\cr #' Confidence level for `"ci"` (default `0.95`). +#' @param position (`Position` or `character`)\cr +#' Position adjustment, either a string (e.g., `"dodge"`) or a +#' formal ggplot2 object (e.g., `ggplot2::position_dodge(width = 0.4)`). +#' Defaults to `ggplot2::position_identity()`. #' #' @return A modified `ggplot2` object with an added error bar layer. #' @@ -556,7 +560,8 @@ gg_varname_extraction <- function(mapping_quo) { gg_add_stats <- function(gg_plt, stat = c("mean", "median"), variability = c("sd", "se", "ci", "iqr", "none"), - conf_level = 0.95) { + conf_level = 0.95, + position = ggplot2::position_identity()) { stat <- match.arg(stat) variability <- match.arg(variability) @@ -571,6 +576,7 @@ gg_add_stats <- function(gg_plt, ), geom = "errorbar", width = 0.45, - na.rm = TRUE + na.rm = TRUE, + position = position ) } diff --git a/man/gg_add_stats.Rd b/man/gg_add_stats.Rd index c52468ba..395cf663 100644 --- a/man/gg_add_stats.Rd +++ b/man/gg_add_stats.Rd @@ -8,7 +8,8 @@ gg_add_stats( gg_plt, stat = c("mean", "median"), variability = c("sd", "se", "ci", "iqr", "none"), - conf_level = 0.95 + conf_level = 0.95, + position = ggplot2::position_identity() ) } \arguments{ @@ -23,6 +24,11 @@ Measure of variability (\code{"sd"}, \code{"se"}, \code{"ci"}, \code{"iqr"}, or \item{conf_level}{(\code{numeric})\cr Confidence level for \code{"ci"} (default \code{0.95}).} + +\item{position}{(\code{Position} or \code{character})\cr +Position adjustment, either a string (e.g., \code{"dodge"}) or a +formal ggplot2 object (e.g., \code{ggplot2::position_dodge(width = 0.4)}). +Defaults to \code{ggplot2::position_identity()}.} } \value{ A modified \code{ggplot2} object with an added error bar layer.