Skip to content

Commit c855013

Browse files
committedNov 27, 2024·
feat: support comparisons = TRUE when group_by is NULL for Box/Violin plot
1 parent a3731f2 commit c855013

4 files changed

+10
-4
lines changed
 

‎R/boxviolinplot.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#' @param highlight_size A numeric value to specify the size of the highlighted points.
5858
#' @param highlight_alpha A numeric value to specify the transparency of the highlighted points.
5959
#' @param comparisons A logical value or a list of vectors to perform pairwise comparisons.
60+
#' If `TRUE`, it will perform pairwise comparisons for all pairs.
6061
#' @param ref_group A character string to specify the reference group for comparisons.
6162
#' @param pairwise_method A character string to specify the pairwise comparison method.
6263
#' @param multiplegroup_comparisons A logical value to perform multiple group comparisons.
@@ -65,6 +66,7 @@
6566
#' @param sig_labelsize A numeric value to specify the size of the significance test label.
6667
#' @return A ggplot object
6768
#' @keywords internal
69+
#' @importFrom utils combn
6870
#' @importFrom stats median quantile
6971
#' @importFrom rlang sym syms parse_expr
7072
#' @importFrom dplyr mutate ungroup first
@@ -114,7 +116,8 @@ BoxViolinPlotAtomic <- function(
114116
)
115117
facet_by <- check_columns(data, facet_by, force_factor = TRUE, allow_multi = TRUE)
116118
if (isTRUE(comparisons) && is.null(group_by)) {
117-
stop("'group_by' must be provided to when 'comparisons' is TRUE.")
119+
# stop("'group_by' must be provided to when 'comparisons' is TRUE.")
120+
comparisons <- combn(levels(data[[x]]), 2, simplify = FALSE)
118121
}
119122
if (isTRUE(multiplegroup_comparisons) || length(comparisons) > 0) {
120123
# if (!requireNamespace("ggpubr", quietly = TRUE)) {

‎man/BoxViolinPlot-internal.Rd

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/BoxViolinPlotAtomic.Rd

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/boxviolinplot.Rd

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.