From aaa9e403cb945f9435dadad3a5087951f861f3e9 Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Thu, 3 Dec 2020 11:59:39 +0100 Subject: [PATCH 01/11] preliminary work von violin plots --- R/apa_factorial_plot.R | 67 ++++++++++++++++++++++++++++++++++++--- man/apa_factorial_plot.Rd | 3 ++ 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/R/apa_factorial_plot.R b/R/apa_factorial_plot.R index 76e150a0..8a8fdb4f 100644 --- a/R/apa_factorial_plot.R +++ b/R/apa_factorial_plot.R @@ -30,6 +30,7 @@ #' @param args_points An optional \code{list} that contains further arguments that may be passed to \code{\link{points}}. #' @param args_lines An optional \code{list} that contains further arguments that may be passed to \code{\link{lines}}. #' @param args_swarm An optional \code{list} that contains further arguments to customize the \code{\link{points}} of the beeswarm. +#' @param args_violins An optional \code{list} that contains further arguments to customize the \code{\link{polygon}} used for violins. #' @param args_error_bars An optional \code{list} that contains further arguments that may be passed to \code{\link{arrows}}. #' @param args_legend An optional \code{list} that contains further arguments that may be passed to \code{\link{legend}} #' @param xlab Character or expression. Label for \emph{x} axis. @@ -102,6 +103,7 @@ apa_factorial_plot.default <- function( , args_points = NULL , args_lines = NULL , args_swarm = NULL + , args_violins = NULL , args_error_bars = NULL , args_legend = NULL , plot = NULL @@ -136,6 +138,7 @@ apa_factorial_plot.default <- function( if(!is.null(args_points)) validate(args_points, check_class = "list") if(!is.null(args_lines)) validate(args_lines, check_class = "list") if(!is.null(args_swarm)) validate(args_swarm, check_class = "list") + if(!is.null(args_violins)) validate(args_violins, check_class = "list") if(!is.null(args_error_bars)) validate(args_error_bars, check_class = "list") if(!is.null(args_legend)) validate(args_legend, check_class = "list") if(!is.null(plot)) validate(plot, check_class = "character") @@ -207,6 +210,7 @@ apa_factorial_plot.default <- function( , args_rect = args_rect , args_points = args_points , args_swarm = args_swarm + , args_violins = args_violins , args_lines = args_lines , args_error_bars = args_error_bars , args_legend = args_legend @@ -537,10 +541,12 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int aggregated$x <- aggregated$x - .5 + space/2 + (1-space)/(nlevels(aggregated[[factors[[2]]]])-1) * (as.integer(aggregated[[factors[2]]])-1) } + # save parameters for multiple plot functions args_legend <- ellipsis$args_legend args_points <- ellipsis$args_points args_swarm <- ellipsis$args_swarm + args_violins <- ellipsis$args_violins args_lines <- ellipsis$args_lines args_x_axis <- ellipsis$args_x_axis args_y_axis <- ellipsis$args_y_axis @@ -553,6 +559,14 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int for(i in whitelist) args_plot_window[[i]] <- ellipsis[[i]] + + ## default colors for tendency points (which are inherited by swarm points) + bg.colors <- grey( + seq(from = 0, to = 1, length.out = nlevels(aggregated[[factors[2]]])) ^ 0.6 + ) + + + # new plot area plot.new() @@ -721,11 +735,6 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int agg.y <- tapply(aggregated[["swarmy"]], list(aggregated[[factors[1]]], aggregated[[factors[2]]]), as.numeric) } - ## default colors for tendency points (which are inherited by swarm points) - nc <- nlevels(aggregated[[factors[2]]])-1 - if(nc==0) nc <- 1 - bg.colors <- grey((0:nc/(nc)) ^ 0.6) - # prepare (tendency) points args_points <- defaults( args_points @@ -741,6 +750,54 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int ) ) + if("violins" %in% ellipsis$plot) { + args_violins <- defaults( + args_violins + , set.if.null = list( + col = args_points$col + , bg = brighten(args_points$bg, factor = .9) + , bw = "SJ" + ) + ) + + args_violins$col <- rep(args_violins$col, each = nlevels(aggregated[[factors[1]]])) + args_violins$bg <- rep(args_violins$bg, each = nlevels(aggregated[[factors[1]]])) + + + merged <- merge(x = aggregated, y.values[, c(factors, "x"), drop = FALSE], sort = FALSE) + + x1 <- split( + x = merged[[dv]] + , f = merged[, factors, drop = FALSE] + ) + + x2 <- lapply(x1, density, bw = args_violins$bw) + + x_offset <- lapply( + split( + x = merged[["x"]] + , f = merged[, factors, drop = FALSE] + ) + , FUN = mean + ) + + max_y <- function(x) { + max(x$y) + } + + max_density <- max(sapply(X = x2, max_y)) * 4 + + for (i in seq_along(x2)) { + polygon( + x = x_offset[[i]] + c(x2[[i]]$y, rev(-x2[[i]]$y)) / max_density + , y = c(x2[[i]]$x, rev(x2[[i]]$x))# / max_density + , col = args_violins$bg[i] + , border = args_violins$col[i] + ) + } + } + + if("swarms" %in% ellipsis$plot){ args_swarm <- defaults( diff --git a/man/apa_factorial_plot.Rd b/man/apa_factorial_plot.Rd index 166ca37f..3efe91dc 100644 --- a/man/apa_factorial_plot.Rd +++ b/man/apa_factorial_plot.Rd @@ -28,6 +28,7 @@ apa_factorial_plot(data, ...) args_points = NULL, args_lines = NULL, args_swarm = NULL, + args_violins = NULL, args_error_bars = NULL, args_legend = NULL, plot = NULL, @@ -102,6 +103,8 @@ case, multiple lines are drawn, where the dimensions of the matrix determine the \item{args_swarm}{An optional \code{list} that contains further arguments to customize the \code{\link{points}} of the beeswarm.} +\item{args_violins}{An optional \code{list} that contains further arguments to customize the \code{\link{density}} estimation used for violins.} + \item{args_error_bars}{An optional \code{list} that contains further arguments that may be passed to \code{\link{arrows}}.} \item{args_legend}{An optional \code{list} that contains further arguments that may be passed to \code{\link{legend}}} From 0bbf1ddaf8e37f2abd3a8c0a9d0947da58c56369 Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Wed, 26 Jun 2024 17:45:25 +0200 Subject: [PATCH 02/11] updated NEWS --- inst/NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/NEWS.md b/inst/NEWS.md index 2b297156..971cb8a7 100644 --- a/inst/NEWS.md +++ b/inst/NEWS.md @@ -1,6 +1,7 @@ # Upcoming release - For ANOVA methods, *MSE*s are again returned if requested by the user (reported by @Sashpta, [#562](https://github.com/crsh/papaja/issues/562)). The global default for reporting *MSE*s now depends on the [**effectsize**](https://CRAN.r-project.org/package=effectsize) package: If **effectsize** is installed, the default for reporting *MSE*s is `FALSE`, if **effectsize** is not installed, the default is `TRUE`. +- `apa_factorial_plot()` gained a new experimental feature to plot density estimates ("violins") of the data. ### Existing functions From b707c2f94b7734e365f7006e7ea9192eddb8932b Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Thu, 27 Jun 2024 08:24:20 +0200 Subject: [PATCH 03/11] allow to specify args_density in apa_factorial_plot() --- R/apa_factorial_plot.R | 16 ++++++++++++---- man/apa_factorial_plot.Rd | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/R/apa_factorial_plot.R b/R/apa_factorial_plot.R index 89578f6f..7718e255 100644 --- a/R/apa_factorial_plot.R +++ b/R/apa_factorial_plot.R @@ -32,6 +32,7 @@ #' @param args_lines An optional `list` that contains further arguments that may be passed to [lines()]. #' @param args_swarm An optional `list` that contains further arguments to customize the [points()] of the beeswarm. #' @param args_violins An optional `list` that contains further arguments to customize the [[polygon()]] used for violins. +#' @param args_density An optional `list` that contains further arguments to customize the densities plotted as violins. #' @param args_error_bars An optional `list` that contains further arguments that may be passed to [arrows()]. #' @param args_legend An optional `list` that contains further arguments that may be passed to [legend()] #' @param xlab Character or expression. Label for *x* axis. @@ -109,6 +110,7 @@ apa_factorial_plot.default <- function( , args_lines = NULL , args_swarm = NULL , args_violins = NULL + , args_density = NULL , args_error_bars = NULL , args_legend = NULL , plot = NULL @@ -144,6 +146,7 @@ apa_factorial_plot.default <- function( if(!is.null(args_lines)) validate(args_lines, check_class = "list") if(!is.null(args_swarm)) validate(args_swarm, check_class = "list") if(!is.null(args_violins)) validate(args_violins, check_class = "list") + if(!is.null(args_density)) validate(args_density, check_class = "list") if(!is.null(args_error_bars)) validate(args_error_bars, check_class = "list") if(!is.null(args_legend)) validate(args_legend, check_class = "list") if(!is.null(plot)) validate(plot, check_class = "character") @@ -216,6 +219,7 @@ apa_factorial_plot.default <- function( , args_points = args_points , args_swarm = args_swarm , args_violins = args_violins + , args_density = args_density , args_lines = args_lines , args_error_bars = args_error_bars , args_legend = args_legend @@ -785,7 +789,11 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int , f = merged[, factors, drop = FALSE] ) - x2 <- lapply(x1, density, bw = "SJ") + if(is.null(ellipsis$args_density)) ellipsis$args_density <- list() + x2 <- lapply(x1, function(x) { + args_density <- defaults(ellipsis$args_density, set.if.null = list(x = x)) + do.call(what = "density", args_density) + }) x_offset <- lapply( split( @@ -799,12 +807,12 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int max(x$y) } - max_density <- max(sapply(X = x2, max_y)) * 4 + max_density <- max(sapply(X = x2, FUN = max_y)) for (i in seq_along(x2)) { polygon( - x = x_offset[[i]] + c(x2[[i]]$y, rev(-x2[[i]]$y)) / max_density - , y = c(x2[[i]]$x, rev(x2[[i]]$x))# / max_density + x = x_offset[[i]] + c(x2[[i]]$y, rev(-x2[[i]]$y)) / max_density * ellipsis$jit / (nlevels(data[[factors[2L]]])-1) + , y = c(x2[[i]]$x, rev(x2[[i]]$x)) , col = args_violins$col[i] , border = args_violins$border[i] ) diff --git a/man/apa_factorial_plot.Rd b/man/apa_factorial_plot.Rd index 0c0907a6..9abbe3fa 100644 --- a/man/apa_factorial_plot.Rd +++ b/man/apa_factorial_plot.Rd @@ -29,6 +29,7 @@ apa_factorial_plot(data, ...) args_lines = NULL, args_swarm = NULL, args_violins = NULL, + args_density = NULL, args_error_bars = NULL, args_legend = NULL, plot = NULL, @@ -103,6 +104,8 @@ case, multiple lines are drawn, where the dimensions of the matrix determine the \item{args_violins}{An optional \code{list} that contains further arguments to customize the [\code{\link[=polygon]{polygon()}}] used for violins.} +\item{args_density}{An optional \code{list} that contains further arguments to customize the densities plotted as violins.} + \item{args_error_bars}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=arrows]{arrows()}}.} \item{args_legend}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=legend]{legend()}}} From cb13bc8d2b73439ef0670b7d8abd558fb50628e4 Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Thu, 27 Jun 2024 13:46:30 +0200 Subject: [PATCH 04/11] violin plots: set x --- R/apa_factorial_plot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/apa_factorial_plot.R b/R/apa_factorial_plot.R index 7718e255..164997e3 100644 --- a/R/apa_factorial_plot.R +++ b/R/apa_factorial_plot.R @@ -791,7 +791,7 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int if(is.null(ellipsis$args_density)) ellipsis$args_density <- list() x2 <- lapply(x1, function(x) { - args_density <- defaults(ellipsis$args_density, set.if.null = list(x = x)) + args_density <- defaults(ellipsis$args_density, set = list(x = x)) do.call(what = "density", args_density) }) From b4c3cd9ece8a41e2856107f138841f8aeff41f60 Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Thu, 27 Jun 2024 14:15:01 +0200 Subject: [PATCH 05/11] link to `density()` in docs --- R/apa_factorial_plot.R | 2 +- man/apa_factorial_plot.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/apa_factorial_plot.R b/R/apa_factorial_plot.R index 164997e3..bde4cc11 100644 --- a/R/apa_factorial_plot.R +++ b/R/apa_factorial_plot.R @@ -32,7 +32,7 @@ #' @param args_lines An optional `list` that contains further arguments that may be passed to [lines()]. #' @param args_swarm An optional `list` that contains further arguments to customize the [points()] of the beeswarm. #' @param args_violins An optional `list` that contains further arguments to customize the [[polygon()]] used for violins. -#' @param args_density An optional `list` that contains further arguments to customize the densities plotted as violins. +#' @param args_density An optional `list` that contains further arguments to customize the [[density()]] plotted as violins. #' @param args_error_bars An optional `list` that contains further arguments that may be passed to [arrows()]. #' @param args_legend An optional `list` that contains further arguments that may be passed to [legend()] #' @param xlab Character or expression. Label for *x* axis. diff --git a/man/apa_factorial_plot.Rd b/man/apa_factorial_plot.Rd index 9abbe3fa..6bb7593d 100644 --- a/man/apa_factorial_plot.Rd +++ b/man/apa_factorial_plot.Rd @@ -104,7 +104,7 @@ case, multiple lines are drawn, where the dimensions of the matrix determine the \item{args_violins}{An optional \code{list} that contains further arguments to customize the [\code{\link[=polygon]{polygon()}}] used for violins.} -\item{args_density}{An optional \code{list} that contains further arguments to customize the densities plotted as violins.} +\item{args_density}{An optional \code{list} that contains further arguments to customize the [\code{\link[=density]{density()}}] plotted as violins.} \item{args_error_bars}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=arrows]{arrows()}}.} From 85c106ac2fb215453f5114016f0a2d02f3b9189e Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Wed, 31 Jul 2024 09:38:51 +0200 Subject: [PATCH 06/11] added function `apa_violinplot()` --- DESCRIPTION | 2 +- NAMESPACE | 3 + R/apa_factorial_plot.R | 5 +- R/apa_lineplot.R | 2 +- R/apa_violinplot.R | 133 +++++++++++++++++++++++++++++ man/apa_barplot.Rd | 3 +- man/apa_beeplot.Rd | 3 +- man/apa_factorial_plot.Rd | 3 +- man/apa_lineplot.Rd | 5 +- man/apa_violinplot.Rd | 172 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 323 insertions(+), 8 deletions(-) create mode 100644 R/apa_violinplot.R create mode 100644 man/apa_violinplot.Rd diff --git a/DESCRIPTION b/DESCRIPTION index ed65de50..70336824 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -58,7 +58,7 @@ SystemRequirements: Rendering the document template requires such as TinyTeX (>= 0.12; https://yihui.org/tinytex/) License: MIT + file LICENSE Encoding: UTF-8 -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 VignetteBuilder: knitr, R.rsp Language: en-US Roxygen: list(markdown = TRUE) diff --git a/NAMESPACE b/NAMESPACE index a3a2b59e..39054715 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -59,6 +59,8 @@ S3method(apa_table,data.frame) S3method(apa_table,default) S3method(apa_table,list) S3method(apa_table,matrix) +S3method(apa_violinplot,afex_aov) +S3method(apa_violinplot,default) S3method(beautify_terms,character) S3method(beautify_terms,data.frame) S3method(beautify_terms,factor) @@ -90,6 +92,7 @@ export(apa_p) export(apa_prepare_doc) export(apa_print) export(apa_table) +export(apa_violinplot) export(beautify_terms) export(ci) export(cite_r) diff --git a/R/apa_factorial_plot.R b/R/apa_factorial_plot.R index bde4cc11..63b48c20 100644 --- a/R/apa_factorial_plot.R +++ b/R/apa_factorial_plot.R @@ -566,6 +566,7 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int args_points <- ellipsis$args_points args_swarm <- ellipsis$args_swarm args_violins <- ellipsis$args_violins + args_density <- ellipsis$args_density args_lines <- ellipsis$args_lines args_x_axis <- ellipsis$args_x_axis args_y_axis <- ellipsis$args_y_axis @@ -811,7 +812,7 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int for (i in seq_along(x2)) { polygon( - x = x_offset[[i]] + c(x2[[i]]$y, rev(-x2[[i]]$y)) / max_density * ellipsis$jit / (nlevels(data[[factors[2L]]])-1) + x = x_offset[[i]] + c(x2[[i]]$y, rev(-x2[[i]]$y)) / max_density * ellipsis$jit / (nlevels(aggregated[[factors[2L]]])-1) , y = c(x2[[i]]$x, rev(x2[[i]]$x)) , col = args_violins$col[i] , border = args_violins$border[i] @@ -945,6 +946,8 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int , args_rect = args_rect , args_points = args_points , args_swarm = args_swarm + , args_violins = args_violins + , args_density = args_density , args_lines = args_lines , args_error_bars = args_error_bars , args_legend = args_legend diff --git a/R/apa_lineplot.R b/R/apa_lineplot.R index 47be1679..ec272762 100644 --- a/R/apa_lineplot.R +++ b/R/apa_lineplot.R @@ -20,7 +20,7 @@ #' , id = "block" #' , dv = "yield" #' , factors = c("N", "P") -#' , args.legend = list(x = "center") +#' , args_legend = list(x = "center") #' , jit = 0 #' ) #' diff --git a/R/apa_violinplot.R b/R/apa_violinplot.R new file mode 100644 index 00000000..964ec834 --- /dev/null +++ b/R/apa_violinplot.R @@ -0,0 +1,133 @@ +#' Violin Plots for Factorial Designs that Conform to APA Guidelines +#' +#' Creates one or more violin plots from a `data.frame` containing data from +#' a factorial design and sets APA-friendly defaults. +#' +#' @inherit apa_factorial_plot +#' @inheritDotParams apa_factorial_plot +#' +#' @family plots for factorial designs +#' @examples +#' apa_violinplot( +#' data = npk +#' , id = "block" +#' , dv = "yield" +#' , factors = c("N") +#' ) +#' +#' apa_violinplot( +#' data = npk +#' , id = "block" +#' , dv = "yield" +#' , factors = c("N", "P") +#' , args_legend = list(x = "center") +#' , jit = 0 +#' ) +#' +#' apa_violinplot( +#' data = npk +#' , id = "block" +#' , dv = "yield" +#' , factors = c("N", "P", "K") +#' , ylim = c(0, 80) +#' , level = .34 +#' , las = 1 +#' ) +#' +#' @import grDevices +#' @import graphics +#' @rdname apa_violinplot +#' @export + +apa_violinplot <- function(data, ...){ + UseMethod("apa_violinplot", data) +} + + + +#' @rdname apa_violinplot +#' @export + +apa_violinplot.default <- function( + data + , id + , factors = NULL + , dv + , tendency = mean + , dispersion = conf_int + , level = 0.95 + , fun_aggregate = mean + , na.rm = TRUE + , use = "all.obs" + , intercept = NULL + , args_x_axis = NULL + , args_y_axis = NULL + , args_title = NULL + , args_points = NULL + , args_lines = NULL + , args_error_bars = NULL + , args_legend = NULL + , jit = .3 + , xlab = NULL + , ylab = NULL + , main = NULL + , ... +){ + ellipsis <- defaults( + list(...) + , set.if.null =list( + data = data + , id = id + , factors = factors + , dv = dv + , tendency = substitute(tendency) + , dispersion = substitute(dispersion) + , level = level + , fun_aggregate = substitute(fun_aggregate) + , na.rm = na.rm + , use = use + , intercept = intercept + , args_x_axis = args_x_axis + , args_y_axis = args_y_axis + , args_points = args_points + , args_lines = args_lines + , args_error_bars = args_error_bars + , args_legend = args_legend + , jit = jit + , xlab = xlab + , ylab = ylab + , main = main + , plot = c("points", "violins") + ) + ) + do.call("apa_factorial_plot", ellipsis) +} + +#' @rdname apa_violinplot +#' @export + +apa_violinplot.afex_aov <- function( + data + , tendency = mean + , dispersion = conf_int + , fun_aggregate = mean + , ... +){ + + ellipsis <- list(...) + + ellipsis <- defaults( + ellipsis + , set = list( + "data" = data + , "plot" = c("lines", "error_bars", "points") + , "tendency" = substitute(tendency) + , "dispersion" = substitute(dispersion) + , "fun_aggregate" = substitute(fun_aggregate) + ) + ) + do.call("apa_factorial_plot.afex_aov", ellipsis) +} + + + diff --git a/man/apa_barplot.Rd b/man/apa_barplot.Rd index d5437073..166b5213 100644 --- a/man/apa_barplot.Rd +++ b/man/apa_barplot.Rd @@ -162,6 +162,7 @@ apa_barplot( Other plots for factorial designs: \code{\link{apa_beeplot}()}, \code{\link{apa_factorial_plot}()}, -\code{\link{apa_lineplot}()} +\code{\link{apa_lineplot}()}, +\code{\link{apa_violinplot}()} } \concept{plots for factorial designs} diff --git a/man/apa_beeplot.Rd b/man/apa_beeplot.Rd index 8be4efc2..2f29d537 100644 --- a/man/apa_beeplot.Rd +++ b/man/apa_beeplot.Rd @@ -165,6 +165,7 @@ apa_beeplot( Other plots for factorial designs: \code{\link{apa_barplot}()}, \code{\link{apa_factorial_plot}()}, -\code{\link{apa_lineplot}()} +\code{\link{apa_lineplot}()}, +\code{\link{apa_violinplot}()} } \concept{plots for factorial designs} diff --git a/man/apa_factorial_plot.Rd b/man/apa_factorial_plot.Rd index 6bb7593d..e23f24b9 100644 --- a/man/apa_factorial_plot.Rd +++ b/man/apa_factorial_plot.Rd @@ -173,6 +173,7 @@ apa_factorial_plot( Other plots for factorial designs: \code{\link{apa_barplot}()}, \code{\link{apa_beeplot}()}, -\code{\link{apa_lineplot}()} +\code{\link{apa_lineplot}()}, +\code{\link{apa_violinplot}()} } \concept{plots for factorial designs} diff --git a/man/apa_lineplot.Rd b/man/apa_lineplot.Rd index b185959a..a862be24 100644 --- a/man/apa_lineplot.Rd +++ b/man/apa_lineplot.Rd @@ -147,7 +147,7 @@ data = npk , id = "block" , dv = "yield" , factors = c("N", "P") - , args.legend = list(x = "center") + , args_legend = list(x = "center") , jit = 0 ) @@ -166,6 +166,7 @@ apa_lineplot( Other plots for factorial designs: \code{\link{apa_barplot}()}, \code{\link{apa_beeplot}()}, -\code{\link{apa_factorial_plot}()} +\code{\link{apa_factorial_plot}()}, +\code{\link{apa_violinplot}()} } \concept{plots for factorial designs} diff --git a/man/apa_violinplot.Rd b/man/apa_violinplot.Rd new file mode 100644 index 00000000..cda11b3c --- /dev/null +++ b/man/apa_violinplot.Rd @@ -0,0 +1,172 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/apa_violinplot.R +\name{apa_violinplot} +\alias{apa_violinplot} +\alias{apa_violinplot.default} +\alias{apa_violinplot.afex_aov} +\title{Violin Plots for Factorial Designs that Conform to APA Guidelines} +\usage{ +apa_violinplot(data, ...) + +\method{apa_violinplot}{default}( + data, + id, + factors = NULL, + dv, + tendency = mean, + dispersion = conf_int, + level = 0.95, + fun_aggregate = mean, + na.rm = TRUE, + use = "all.obs", + intercept = NULL, + args_x_axis = NULL, + args_y_axis = NULL, + args_title = NULL, + args_points = NULL, + args_lines = NULL, + args_error_bars = NULL, + args_legend = NULL, + jit = 0.3, + xlab = NULL, + ylab = NULL, + main = NULL, + ... +) + +\method{apa_violinplot}{afex_aov}( + data, + tendency = mean, + dispersion = conf_int, + fun_aggregate = mean, + ... +) +} +\arguments{ +\item{data}{A \code{data.frame} that contains the data, or an object of class \code{afex_aov}.} + +\item{...}{ + Arguments passed on to \code{\link[=apa_factorial_plot]{apa_factorial_plot}} + \describe{ + \item{\code{}}{} + }} + +\item{id}{Character. Variable name that identifies subjects.} + +\item{factors}{Character. A vector of up to four variable names that is used to stratify the data.} + +\item{dv}{Character. The name of the dependent variable.} + +\item{tendency}{Closure. A function that will be used as measure of central tendency.} + +\item{dispersion}{Closure. A function that will be used to construct error bars (i.e., whiskers). Defaults to +\code{\link[=conf_int]{conf_int()}} for 95\% between-subjects confidence intervals. See details for more options, especially for within-subjects confidence intervals.} + +\item{level}{Numeric. Defines the width of the interval if confidence intervals are plotted. Defaults to \code{0.95}. +for 95\% confidence intervals. Ignored if \code{dispersion} is not a confidence-interval function. See details.} + +\item{fun_aggregate}{Closure. The function that will be used to aggregate observations within subjects and factors +before calculating descriptive statistics for each cell of the design. Defaults to \code{mean}.} + +\item{na.rm}{Logical. Specifies if missing values are removed. Defaults to \code{TRUE}.} + +\item{use}{Character. Specifies a method to exclude cases if there are missing values \emph{after} aggregating. +Possible options are \code{"all.obs"} or \code{"complete.obs"}.} + +\item{intercept}{Numeric. Adds a horizontal line at height \code{intercept} to the plot. Can be either a single value or a matrix. For the matrix +case, multiple lines are drawn, where the dimensions of the matrix determine the number of lines to be drawn.} + +\item{args_x_axis}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=axis]{axis()}} for customizing the \emph{x} axis.} + +\item{args_y_axis}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=axis]{axis()}} for customizing the \emph{y} axis.} + +\item{args_title}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=title]{title()}}.} + +\item{args_points}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=points]{points()}}.} + +\item{args_lines}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=lines]{lines()}}.} + +\item{args_error_bars}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=arrows]{arrows()}}.} + +\item{args_legend}{An optional \code{list} that contains further arguments that may be passed to \code{\link[=legend]{legend()}}} + +\item{jit}{Numeric. Determines the amount of horizontal displacement. Defaults to \code{0.3}, defaults to \code{0.4} if \code{plot = "bars"}.} + +\item{xlab}{Character or expression. Label for \emph{x} axis.} + +\item{ylab}{Character or expression. Label for \emph{y} axis.} + +\item{main}{Character or expression. For up to two factors, simply specify the main title. If you stratify the data by more than two factors, +either specify a single value that will be added to automatically generated main title, \emph{or} specify an array of multiple titles, one for each plot area.} +} +\value{ +A named (nested) list of plot options including raw and derived data. \emph{Note that the structure of the return value is about to change in a forthcoming release of papaja.} +} +\description{ +Creates one or more violin plots from a \code{data.frame} containing data from +a factorial design and sets APA-friendly defaults. +} +\details{ +The measure of dispersion can be either \code{\link[=conf_int]{conf_int()}} for between-subjects confidence intervals, \code{\link[=se]{se()}} for standard errors, +or any other standard function. For within-subjects confidence intervals, specify \code{\link[=wsci]{wsci()}} or \code{\link[=within_subjects_conf_int]{within_subjects_conf_int()}}. + +If between- or within-subjects confidence intervals are requested, you can also specify the area of the cumulative +distribution function that will be covered. For instance, if you want a 98\% confidence interval, specify +\code{level = 0.98}. The default is \code{level = 0.95} for 95\% confidence intervals. +\subsection{Customization of plot elements}{ + +\code{\link[=apa_factorial_plot]{apa_factorial_plot()}} and its descendants \code{\link[=apa_barplot]{apa_barplot()}}, \code{\link[=apa_lineplot]{apa_lineplot()}}, +and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequentially call: +\itemize{ +\item \code{\link[=plot.new]{plot.new()}}, +\item \code{\link[=plot.window]{plot.window()}}, +\item \code{\link[=axis]{axis()}} (once for \emph{x} axis, once for \emph{y} axis), +\item \code{\link[=title]{title()}} for axis labels and titles, +\item \code{\link[=rect]{rect()}} for bars in bar plots, +\item \code{\link[=points]{points()}} for bee swarms, +\item \code{\link[=lines]{lines()}} for lines connecting central tendency points, +\item \code{\link[=arrows]{arrows()}} for error bars, +\item \code{\link[=points]{points()}} for tendency points, +\item \code{\link[=legend]{legend()}} for a legend, and +\item \code{\link[=lines]{lines()}} for intercepts. +} + +These calls can be customized by setting the respective parameters \verb{args_*** = list(...)}. +} +} +\examples{ +apa_violinplot( + data = npk + , id = "block" + , dv = "yield" + , factors = c("N") +) + +apa_violinplot( +data = npk + , id = "block" + , dv = "yield" + , factors = c("N", "P") + , args_legend = list(x = "center") + , jit = 0 +) + +apa_violinplot( + data = npk + , id = "block" + , dv = "yield" + , factors = c("N", "P", "K") + , ylim = c(0, 80) + , level = .34 + , las = 1 +) + +} +\seealso{ +Other plots for factorial designs: +\code{\link{apa_barplot}()}, +\code{\link{apa_beeplot}()}, +\code{\link{apa_factorial_plot}()}, +\code{\link{apa_lineplot}()} +} +\concept{plots for factorial designs} From 4700fd3b9fd10b37f3aec7e78fe0e9b6403dbbc0 Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Thu, 1 Aug 2024 08:08:52 +0200 Subject: [PATCH 07/11] apa_violinplot(): also plot error bars as per default --- R/apa_violinplot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/apa_violinplot.R b/R/apa_violinplot.R index 964ec834..acae0238 100644 --- a/R/apa_violinplot.R +++ b/R/apa_violinplot.R @@ -97,7 +97,7 @@ apa_violinplot.default <- function( , xlab = xlab , ylab = ylab , main = main - , plot = c("points", "violins") + , plot = c("points", "violins", "error_bars") ) ) do.call("apa_factorial_plot", ellipsis) From 16969fb25f44eec1b6c41477b6693ea7fcaf388d Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Thu, 1 Aug 2024 08:11:18 +0200 Subject: [PATCH 08/11] updated docs --- R/apa_factorial_plot.R | 3 ++- man/apa_barplot.Rd | 3 ++- man/apa_beeplot.Rd | 3 ++- man/apa_factorial_plot.Rd | 3 ++- man/apa_lineplot.Rd | 3 ++- man/apa_print.aov.Rd | 11 ++++++----- man/apa_violinplot.Rd | 3 ++- man/lookup_tables.Rd | 4 ++-- 8 files changed, 20 insertions(+), 13 deletions(-) diff --git a/R/apa_factorial_plot.R b/R/apa_factorial_plot.R index 4ed96d68..b2732e20 100644 --- a/R/apa_factorial_plot.R +++ b/R/apa_factorial_plot.R @@ -53,7 +53,7 @@ #' ## Customization of plot elements #' #' [apa_factorial_plot()] and its descendants [apa_barplot()], [apa_lineplot()], -#' and [apa_beeplot()] are wrapper functions that sequentially call: +#' [apa_beeplot()], and [apa_violinplot()] are wrapper functions that sequentially call: #' #' - [plot.new()], #' - [plot.window()], @@ -61,6 +61,7 @@ #' - [title()] for axis labels and titles, #' - [rect()] for bars in bar plots, #' - [points()] for bee swarms, +#' - [density()] and [polygon()] for violins, #' - [lines()] for lines connecting central tendency points, #' - [arrows()] for error bars, #' - [points()] for tendency points, diff --git a/man/apa_barplot.Rd b/man/apa_barplot.Rd index 3d7a99f3..f93e6926 100644 --- a/man/apa_barplot.Rd +++ b/man/apa_barplot.Rd @@ -116,7 +116,7 @@ distribution function that will be covered. For instance, if you want a 98\% con \subsection{Customization of plot elements}{ \code{\link[=apa_factorial_plot]{apa_factorial_plot()}} and its descendants \code{\link[=apa_barplot]{apa_barplot()}}, \code{\link[=apa_lineplot]{apa_lineplot()}}, -and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequentially call: +\code{\link[=apa_beeplot]{apa_beeplot()}}, and \code{\link[=apa_violinplot]{apa_violinplot()}} are wrapper functions that sequentially call: \itemize{ \item \code{\link[=plot.new]{plot.new()}}, \item \code{\link[=plot.window]{plot.window()}}, @@ -124,6 +124,7 @@ and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequent \item \code{\link[=title]{title()}} for axis labels and titles, \item \code{\link[=rect]{rect()}} for bars in bar plots, \item \code{\link[=points]{points()}} for bee swarms, +\item \code{\link[=density]{density()}} and \code{\link[=polygon]{polygon()}} for violins, \item \code{\link[=lines]{lines()}} for lines connecting central tendency points, \item \code{\link[=arrows]{arrows()}} for error bars, \item \code{\link[=points]{points()}} for tendency points, diff --git a/man/apa_beeplot.Rd b/man/apa_beeplot.Rd index 17c667c4..21ec8e91 100644 --- a/man/apa_beeplot.Rd +++ b/man/apa_beeplot.Rd @@ -119,7 +119,7 @@ distribution function that will be covered. For instance, if you want a 98\% con \subsection{Customization of plot elements}{ \code{\link[=apa_factorial_plot]{apa_factorial_plot()}} and its descendants \code{\link[=apa_barplot]{apa_barplot()}}, \code{\link[=apa_lineplot]{apa_lineplot()}}, -and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequentially call: +\code{\link[=apa_beeplot]{apa_beeplot()}}, and \code{\link[=apa_violinplot]{apa_violinplot()}} are wrapper functions that sequentially call: \itemize{ \item \code{\link[=plot.new]{plot.new()}}, \item \code{\link[=plot.window]{plot.window()}}, @@ -127,6 +127,7 @@ and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequent \item \code{\link[=title]{title()}} for axis labels and titles, \item \code{\link[=rect]{rect()}} for bars in bar plots, \item \code{\link[=points]{points()}} for bee swarms, +\item \code{\link[=density]{density()}} and \code{\link[=polygon]{polygon()}} for violins, \item \code{\link[=lines]{lines()}} for lines connecting central tendency points, \item \code{\link[=arrows]{arrows()}} for error bars, \item \code{\link[=points]{points()}} for tendency points, diff --git a/man/apa_factorial_plot.Rd b/man/apa_factorial_plot.Rd index 7c605f61..8f77e7dc 100644 --- a/man/apa_factorial_plot.Rd +++ b/man/apa_factorial_plot.Rd @@ -143,7 +143,7 @@ distribution function that will be covered. For instance, if you want a 98\% con \subsection{Customization of plot elements}{ \code{\link[=apa_factorial_plot]{apa_factorial_plot()}} and its descendants \code{\link[=apa_barplot]{apa_barplot()}}, \code{\link[=apa_lineplot]{apa_lineplot()}}, -and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequentially call: +\code{\link[=apa_beeplot]{apa_beeplot()}}, and \code{\link[=apa_violinplot]{apa_violinplot()}} are wrapper functions that sequentially call: \itemize{ \item \code{\link[=plot.new]{plot.new()}}, \item \code{\link[=plot.window]{plot.window()}}, @@ -151,6 +151,7 @@ and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequent \item \code{\link[=title]{title()}} for axis labels and titles, \item \code{\link[=rect]{rect()}} for bars in bar plots, \item \code{\link[=points]{points()}} for bee swarms, +\item \code{\link[=density]{density()}} and \code{\link[=polygon]{polygon()}} for violins, \item \code{\link[=lines]{lines()}} for lines connecting central tendency points, \item \code{\link[=arrows]{arrows()}} for error bars, \item \code{\link[=points]{points()}} for tendency points, diff --git a/man/apa_lineplot.Rd b/man/apa_lineplot.Rd index db5ee0bf..15b6ee0a 100644 --- a/man/apa_lineplot.Rd +++ b/man/apa_lineplot.Rd @@ -119,7 +119,7 @@ distribution function that will be covered. For instance, if you want a 98\% con \subsection{Customization of plot elements}{ \code{\link[=apa_factorial_plot]{apa_factorial_plot()}} and its descendants \code{\link[=apa_barplot]{apa_barplot()}}, \code{\link[=apa_lineplot]{apa_lineplot()}}, -and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequentially call: +\code{\link[=apa_beeplot]{apa_beeplot()}}, and \code{\link[=apa_violinplot]{apa_violinplot()}} are wrapper functions that sequentially call: \itemize{ \item \code{\link[=plot.new]{plot.new()}}, \item \code{\link[=plot.window]{plot.window()}}, @@ -127,6 +127,7 @@ and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequent \item \code{\link[=title]{title()}} for axis labels and titles, \item \code{\link[=rect]{rect()}} for bars in bar plots, \item \code{\link[=points]{points()}} for bee swarms, +\item \code{\link[=density]{density()}} and \code{\link[=polygon]{polygon()}} for violins, \item \code{\link[=lines]{lines()}} for lines connecting central tendency points, \item \code{\link[=arrows]{arrows()}} for error bars, \item \code{\link[=points]{points()}} for tendency points, diff --git a/man/apa_print.aov.Rd b/man/apa_print.aov.Rd index e546436c..29b8a840 100644 --- a/man/apa_print.aov.Rd +++ b/man/apa_print.aov.Rd @@ -11,7 +11,7 @@ \alias{apa_print.anova} \alias{apa_print.manova} \alias{apa_print.summary.manova} -\title{Typeset Statistical Results from ANOVA} +\title{Typeset Statistical Results from Analysis of Variance (or Deviance)} \usage{ \method{apa_print}{aov}( x, @@ -136,10 +136,11 @@ or \code{"none"} for no correction.} reported, see \code{\link[stats]{summary.manova}}.} } \description{ -These methods take objects from various R functions that calculate ANOVA to -create formatted character strings to report the results in accordance with -APA manuscript guidelines. For \code{anova}-objects from model comparisons see -\code{\link{apa_print.list}}. +These methods take objects from various R functions that calculate analysis +of variance (i.e., ANOVA) or analysis of deviance. They create formatted +character strings to report the results in accordance with APA manuscript +guidelines. For \code{anova}-objects from model comparisons see +\code{\link[=apa_print.list]{apa_print.list()}}. } \details{ The factor names are sanitized to facilitate their use as list names (see diff --git a/man/apa_violinplot.Rd b/man/apa_violinplot.Rd index cda11b3c..03c3b55d 100644 --- a/man/apa_violinplot.Rd +++ b/man/apa_violinplot.Rd @@ -116,7 +116,7 @@ distribution function that will be covered. For instance, if you want a 98\% con \subsection{Customization of plot elements}{ \code{\link[=apa_factorial_plot]{apa_factorial_plot()}} and its descendants \code{\link[=apa_barplot]{apa_barplot()}}, \code{\link[=apa_lineplot]{apa_lineplot()}}, -and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequentially call: +\code{\link[=apa_beeplot]{apa_beeplot()}}, and \code{\link[=apa_violinplot]{apa_violinplot()}} are wrapper functions that sequentially call: \itemize{ \item \code{\link[=plot.new]{plot.new()}}, \item \code{\link[=plot.window]{plot.window()}}, @@ -124,6 +124,7 @@ and \code{\link[=apa_beeplot]{apa_beeplot()}} are wrapper functions that sequent \item \code{\link[=title]{title()}} for axis labels and titles, \item \code{\link[=rect]{rect()}} for bars in bar plots, \item \code{\link[=points]{points()}} for bee swarms, +\item \code{\link[=density]{density()}} and \code{\link[=polygon]{polygon()}} for violins, \item \code{\link[=lines]{lines()}} for lines connecting central tendency points, \item \code{\link[=arrows]{arrows()}} for error bars, \item \code{\link[=points]{points()}} for tendency points, diff --git a/man/lookup_tables.Rd b/man/lookup_tables.Rd index 941f46fa..cd173ea3 100644 --- a/man/lookup_tables.Rd +++ b/man/lookup_tables.Rd @@ -7,9 +7,9 @@ \alias{lookup_adjust_names} \title{Lookup Tables for Column Names and Variable Labels} \format{ -An object of class \code{character} of length 108. +An object of class \code{character} of length 116. -An object of class \code{character} of length 103. +An object of class \code{character} of length 110. } \usage{ lookup_names From b3932338848f62dd864708aa7a3914f7012537ac Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Thu, 1 Aug 2024 08:25:26 +0200 Subject: [PATCH 09/11] apa_violinplot(): handle single-factor case --- R/apa_factorial_plot.R | 12 ++++-------- R/apa_violinplot.R | 21 ++++++--------------- man/apa_violinplot.Rd | 12 ++++++------ 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/R/apa_factorial_plot.R b/R/apa_factorial_plot.R index b2732e20..4b246a20 100644 --- a/R/apa_factorial_plot.R +++ b/R/apa_factorial_plot.R @@ -784,8 +784,8 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int ) ) - args_violins$border <- rep(args_violins$border, each = nlevels(aggregated[[factors[1]]])) - args_violins$col <- rep(args_violins$col, each = nlevels(aggregated[[factors[1]]])) + args_violins$border <- rep(args_violins$border, each = nlevels(aggregated[[factors[1L]]])) + args_violins$col <- rep(args_violins$col, each = nlevels(aggregated[[factors[1L]]])) merged <- merge(x = aggregated, y.values[, c(factors, "x"), drop = FALSE], sort = FALSE) @@ -809,15 +809,11 @@ apa_factorial_plot_single <- function(aggregated, y.values, id, dv, factors, int , FUN = mean ) - max_y <- function(x) { - max(x$y) - } - - max_density <- max(sapply(X = x2, FUN = max_y)) + max_density <- max(sapply(X = x2, FUN = function(x) {max(x$y)})) for (i in seq_along(x2)) { polygon( - x = x_offset[[i]] + c(x2[[i]]$y, rev(-x2[[i]]$y)) / max_density * ellipsis$jit / (nlevels(aggregated[[factors[2L]]])-1) + x = x_offset[[i]] + c(x2[[i]]$y, rev(-x2[[i]]$y)) / max_density * ellipsis$jit / (if(onedim) 1 else nlevels(aggregated[[factors[2L]]])-1) , y = c(x2[[i]]$x, rev(x2[[i]]$x)) , col = args_violins$col[i] , border = args_violins$border[i] diff --git a/R/apa_violinplot.R b/R/apa_violinplot.R index acae0238..7398f1cb 100644 --- a/R/apa_violinplot.R +++ b/R/apa_violinplot.R @@ -16,23 +16,14 @@ #' ) #' #' apa_violinplot( -#' data = npk -#' , id = "block" -#' , dv = "yield" -#' , factors = c("N", "P") -#' , args_legend = list(x = "center") -#' , jit = 0 +#' data = npk +#' , id = "block" +#' , dv = "yield" +#' , factors = c("N", "P") +#' , args_legend = list(x = "center") +#' , jit = 0.1 #' ) #' -#' apa_violinplot( -#' data = npk -#' , id = "block" -#' , dv = "yield" -#' , factors = c("N", "P", "K") -#' , ylim = c(0, 80) -#' , level = .34 -#' , las = 1 -#' ) #' #' @import grDevices #' @import graphics diff --git a/man/apa_violinplot.Rd b/man/apa_violinplot.Rd index 03c3b55d..9ae6c3ab 100644 --- a/man/apa_violinplot.Rd +++ b/man/apa_violinplot.Rd @@ -144,12 +144,12 @@ apa_violinplot( ) apa_violinplot( -data = npk - , id = "block" - , dv = "yield" - , factors = c("N", "P") - , args_legend = list(x = "center") - , jit = 0 + data = npk + , id = "block" + , dv = "yield" + , factors = c("N", "P") + , args_legend = list(x = "center") + , jit = 0 ) apa_violinplot( From 5b920dc2d979fe3692a6754a75df3dabb180458d Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Thu, 1 Aug 2024 08:33:19 +0200 Subject: [PATCH 10/11] updated docs --- man/apa_violinplot.Rd | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/man/apa_violinplot.Rd b/man/apa_violinplot.Rd index 9ae6c3ab..c471d1af 100644 --- a/man/apa_violinplot.Rd +++ b/man/apa_violinplot.Rd @@ -149,18 +149,9 @@ apa_violinplot( , dv = "yield" , factors = c("N", "P") , args_legend = list(x = "center") - , jit = 0 + , jit = 0.1 ) -apa_violinplot( - data = npk - , id = "block" - , dv = "yield" - , factors = c("N", "P", "K") - , ylim = c(0, 80) - , level = .34 - , las = 1 -) } \seealso{ From 00a9294fc65d8fcd24496ce17f2d61abee7b4e03 Mon Sep 17 00:00:00 2001 From: mariusbarth Date: Sun, 4 Aug 2024 22:13:34 +0200 Subject: [PATCH 11/11] apa_violinplot.afex_aov(): really plot violins, not segments --- R/apa_violinplot.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/apa_violinplot.R b/R/apa_violinplot.R index 7398f1cb..35269642 100644 --- a/R/apa_violinplot.R +++ b/R/apa_violinplot.R @@ -110,11 +110,11 @@ apa_violinplot.afex_aov <- function( ellipsis <- defaults( ellipsis , set = list( - "data" = data - , "plot" = c("lines", "error_bars", "points") - , "tendency" = substitute(tendency) - , "dispersion" = substitute(dispersion) - , "fun_aggregate" = substitute(fun_aggregate) + data = data + , plot = c("points", "violins", "error_bars") + , tendency = substitute(tendency) + , dispersion = substitute(dispersion) + , fun_aggregate = substitute(fun_aggregate) ) ) do.call("apa_factorial_plot.afex_aov", ellipsis)