gg_groupplot {scipub} | R Documentation |
Create ggplot to display group differences (box+point+hist)
Description
The gg_groupplot
function can be used to create group
difference plots for scientific publication.
This is intended to summarize a continuous outcome (y
)
based on a factor ('x') from an input dataset (data
).
The plot will include standard ggplot2::geom_boxplot
indicating 25th, median, and 75th percentile for the box
and 1.5 * IQR for the whiskers. Outliers are not
highlighted.
Raw data is displayed with standard ggplot2::geom_point
and lateral but not vertical jittering.
Histograms are shown with gghalves::geom_half_violin
to the right of each boxplot.
If meanline = = TRUE (default), gray dots will indicate
the mean for each variable (vs. median in boxplot)
connected by a gray line.
This function will drop any NA values.
Requires ggplot2
and gghalves
libraries.
Usage
gg_groupplot(data, x, y, meanline = c(TRUE, FALSE))
Arguments
data |
The input dataset. |
x |
The grouping factor, e.g. Sex |
y |
The numeric outcome variable, e.g. Age |
meanline |
Optional indicator of means |
Value
Output group plot
Examples
gg_groupplot(data = psydat, x = Sex, y = depressT, meanline = TRUE)