diff --git a/.gitignore b/.gitignore index 380268bc3..f0c49498e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +ggstatsplot.Rproj Meta doc docs diff --git a/R/ggbetweenstats.R b/R/ggbetweenstats.R index e1f0a844e..cbb93fea1 100644 --- a/R/ggbetweenstats.R +++ b/R/ggbetweenstats.R @@ -139,10 +139,11 @@ #' point.args = list(alpha = 0) #' ) #' @export -ggbetweenstats <- function( +ggbetweenstats_test <- function( data, x, y, + plot.type = "boxviolin", type = "parametric", pairwise.display = "significant", p.adjust.method = "holm", @@ -227,10 +228,26 @@ ggbetweenstats <- function( # plot ----------------------------------- - plot_comparison <- ggplot(data, mapping = aes({{ x }}, {{ y }})) + - exec(geom_point, aes(color = {{ x }}), !!!point.args) + - exec(geom_boxplot, !!!boxplot.args, outlier.shape = NA) + - exec(geom_violin, !!!violin.args) + # Check plot type and choose the appropriate plot + if (plot.type == "boxviolin") { + # Plot with both box and violin plots + plot_comparison <- ggplot(data, mapping = aes({{ x }}, {{ y }})) + + exec(geom_point, aes(color = {{ x }}), !!!point.args) + + exec(geom_boxplot, !!!boxplot.args, outlier.shape = NA) + + exec(geom_violin, !!!violin.args) + } else if (plot.type == "box") { + # Only boxplot + plot_comparison <- ggplot(data, mapping = aes({{ x }}, {{ y }})) + + exec(geom_point, aes(color = {{ x }}), !!!point.args) + + exec(geom_boxplot, !!!boxplot.args, outlier.shape = NA) + } else if (plot.type == "violin") { + # Only violin plot + plot_comparison <- ggplot(data, mapping = aes({{ x }}, {{ y }})) + + exec(geom_point, aes(color = {{ x }}), !!!point.args) + + exec(geom_violin, !!!violin.args) + } else { + stop("Invalid plot type. Please choose from 'boxviolin', 'box', or 'violin'.") + } # centrality tagging ------------------------------------- @@ -362,3 +379,4 @@ grouped_ggbetweenstats <- function( purrr::pmap(.f = ggbetweenstats, ...) %>% combine_plots(plotgrid.args, annotation.args) } + diff --git a/ggstatsplot.Rproj b/ggstatsplot.Rproj index 3c250ee8b..dedff2f80 100644 --- a/ggstatsplot.Rproj +++ b/ggstatsplot.Rproj @@ -1,5 +1,4 @@ Version: 1.0 -ProjectId: ab06f9e0-823d-4ff7-bf03-7b91e3815731 RestoreWorkspace: No SaveWorkspace: No