Make nice violin plots easily with 95% (possibly bootstrapped) confidence intervals.
nice_violin(
data,
response,
group = NULL,
boot = FALSE,
bootstraps = 2000,
colours,
xlabels = NULL,
ytitle = response,
xtitle = NULL,
has.ylabels = TRUE,
has.xlabels = TRUE,
comp1 = 1,
comp2 = 2,
signif_annotation = NULL,
signif_yposition = NULL,
signif_xmin = NULL,
signif_xmax = NULL,
ymin,
ymax,
yby = 1,
CIcap.width = 0.1,
obs = FALSE,
alpha = 1,
border.colour = "black",
border.size = 2,
has.d = FALSE,
d.x = mean(c(comp1, comp2)) * 1.1,
d.y = mean(data[[response]]) * 1.3,
groups.order = "none",
xlabels.angle = 0
)
A violin plot of class ggplot, by group.
The data frame.
The dependent variable to be plotted.
The group by which to plot the variable.
Logical, whether to use bootstrapping for the confidence interval or not.
How many bootstraps to use.
Desired colours for the plot, if desired.
The individual group labels on the x-axis.
An optional y-axis label, if desired.
An optional x-axis label, if desired.
Logical, whether the x-axis should have labels or not.
Logical, whether the y-axis should have labels or not.
The first unit of a pairwise comparison, if the
goal is to compare two groups. Automatically displays *
,
**
, or ***
depending on significance of the difference.
Can take either a numeric value (based on the group number)
or the name of the group directly. Must be provided along
with argument comp2
.
The second unit of a pairwise comparison, if
the goal is to compare two groups. Automatically displays
"", "", or "" depending on significance of the
difference. Can take either a numeric value (based on the
group number) or the name of the group directly. Must be
provided along with argument comp1
.
Manually provide the required
annotations/numbers of stars (as character strings).
Useful if the automatic pairwise comparison annotation
does not work as expected, or yet if one wants more than
one pairwise comparison. Must be provided along with
arguments signif_yposition
, signif_xmin
, and signif_xmax
.
Manually provide the vertical position of the annotations/stars, based on the y-scale.
Manually provide the first part of the horizontal position of the annotations/stars (start of the left-sided bracket), based on the x-scale.
Manually provide the second part of the horizontal position of the annotations/stars (end of the right-sided bracket), based on the x-scale.
The minimum score on the y-axis scale.
The maximum score on the y-axis scale.
How much to increase on each "tick" on the y-axis scale.
The width of the confidence interval cap.
Logical, whether to plot individual observations or not.
The type of plotting can also be specified, either "dotplot"
(same
as obs = TRUE
for backward compatibility) or "jitter"
,
useful when there are a lot of observations.
The transparency of the plot.
The colour of the violins border.
The size of the violins border.
Whether to display the d-value.
The x-axis coordinates for the d-value.
The y-axis coordinates for the d-value.
How to order the group factor levels on the x-axis. Either "increasing" or "decreasing", to order based on the value of the variable on the y axis, or "string.length", to order from the shortest to the longest string (useful when working with long string names). "Defaults to "none".
How much to tilt the labels of the x-axis. Useful when working with long string names. "Defaults to 0.
Using boot = TRUE
uses bootstrapping (for the
confidence intervals only) with the BCa method, using
the rcompanion_groupwiseMean function.
For the easystats equivalent, see: see::geom_violindot()
.
Visualize group differences via scatter plots:
nice_scatter
. Tutorial:
https://rempsyc.remi-theriault.com/articles/violin