View source: R/apa_violinplot.R
apa_violinplot | R Documentation |
Creates one or more violin plots from a data.frame
containing data from
a factorial design and sets APA-friendly defaults.
apa_violinplot(data, ...)
## Default S3 method:
apa_violinplot(
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,
...
)
## S3 method for class 'afex_aov'
apa_violinplot(
data,
tendency = mean,
dispersion = conf_int,
fun_aggregate = mean,
...
)
data |
A |
... |
Further arguments passed on to |
id |
Character. Variable name that identifies subjects. |
factors |
Character. A vector of up to four variable names that is used to stratify the data. |
dv |
Character. The name of the dependent variable. |
tendency |
Closure. A function that will be used as measure of central tendency. |
dispersion |
Closure. A function that will be used to construct error bars (i.e., whiskers). Defaults to
|
level |
Numeric. Defines the width of the interval if confidence intervals are plotted. Defaults to |
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 |
na.rm |
Logical. Specifies if missing values are removed. Defaults to |
use |
Character. Specifies a method to exclude cases if there are missing values after aggregating.
Possible options are |
intercept |
Numeric. Adds a horizontal line at height |
args_x_axis |
An optional |
args_y_axis |
An optional |
args_title |
An optional |
args_points |
An optional |
args_lines |
An optional |
args_error_bars |
An optional |
args_legend |
An optional |
jit |
Numeric. Determines the amount of horizontal displacement. Defaults to |
xlab |
Character or expression. Label for x axis. |
ylab |
Character or expression. Label for y axis. |
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, or specify an array of multiple titles, one for each plot area. |
The measure of dispersion can be either conf_int()
for between-subjects confidence intervals, se()
for standard errors,
or any other standard function. For within-subjects confidence intervals, specify wsci()
or 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
level = 0.98
. The default is level = 0.95
for 95% confidence intervals.
apa_factorial_plot()
and its descendants apa_barplot()
, apa_lineplot()
,
apa_beeplot()
, and apa_violinplot()
are wrapper functions that sequentially call:
plot.new()
,
plot.window()
,
axis()
(once for x axis, once for y axis),
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,
legend()
for a legend, and
lines()
for intercepts.
These calls can be customized by setting the respective parameters args_*** = list(...)
.
A named (nested) list of plot options including raw and derived data. Note that the structure of the return value is about to change in a forthcoming release of papaja.
Other plots for factorial designs:
apa_barplot()
,
apa_beeplot()
,
apa_factorial_plot()
,
apa_lineplot()
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.1
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.