From 98c94f033547219bda8372b1e2cac20b3dbecad5 Mon Sep 17 00:00:00 2001 From: Andreas Busjahn Date: Fri, 24 Nov 2023 13:52:44 +0100 Subject: [PATCH] fixed bug in parameter use and doc in label_outlier --- R/plots.R | 4 +++- man/label_outliers.Rd | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/R/plots.R b/R/plots.R index b767f65..711d476 100644 --- a/R/plots.R +++ b/R/plots.R @@ -238,8 +238,9 @@ ggcormat <- function(cor_mat, p_mat = NULL, #' @return A ggplot object, allowing further styling. #' # ' @examples +# todo: group by facet variables #' @export -label_outliers <- function(plotbase, xvar, #yvar, labelvar, +label_outliers <- function(plotbase, labelvar, #xvar, #yvar, coef=1.5, nudge_x=0, nudge_y=0, color="darkred", size=3, hjust=0) { if(!requireNamespace("ggrepel", quietly = TRUE)) { @@ -253,6 +254,7 @@ label_outliers <- function(plotbase, xvar, #yvar, labelvar, str_replace('^.+\\"(.+)\\".*',"\\1") plotbase + ggrepel::geom_text_repel(data=. %>% + # todo: group by facet variables group_by(!!sym(xvar)) %>% filter(!!sym(yvar) %in% boxplot.stats(!!sym(yvar), diff --git a/man/label_outliers.Rd b/man/label_outliers.Rd index ad0129f..14ae473 100644 --- a/man/label_outliers.Rd +++ b/man/label_outliers.Rd @@ -6,7 +6,7 @@ \usage{ label_outliers( plotbase, - xvar, + labelvar, coef = 1.5, nudge_x = 0, nudge_y = 0, @@ -18,6 +18,8 @@ label_outliers( \arguments{ \item{plotbase}{ggplot object to add labels to.} +\item{labelvar}{variable to use as label.} + \item{coef}{coefficient for boxplot.stats, defaults to 1.5.} \item{nudge_x}{nudge in x direction, defaults to 0.} @@ -29,8 +31,6 @@ label_outliers( \item{size}{size of labels, defaults to 3.} \item{hjust}{horizontal justification of labels, defaults to 0.} - -\item{labelvar}{variable to use as label.} } \value{ A ggplot object, allowing further styling.