Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ggstatsplot.Rproj
Meta
doc
docs
Expand Down
28 changes: 23 additions & 5 deletions R/ggbetweenstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 -------------------------------------

Expand Down Expand Up @@ -362,3 +379,4 @@ grouped_ggbetweenstats <- function(
purrr::pmap(.f = ggbetweenstats, ...) %>%
combine_plots(plotgrid.args, annotation.args)
}

1 change: 0 additions & 1 deletion ggstatsplot.Rproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Version: 1.0
ProjectId: ab06f9e0-823d-4ff7-bf03-7b91e3815731

RestoreWorkspace: No
SaveWorkspace: No
Expand Down