plot_group_means {kim} | R Documentation |
Plot group means
Description
Creates a plot of sample means and error bars by group.
Usage
plot_group_means(
data = NULL,
dv_name = NULL,
iv_name = NULL,
na.rm = TRUE,
error_bar = "ci",
error_bar_range = 0.95,
error_bar_tip_width = 0.13,
error_bar_thickness = 1,
error_bar_caption = TRUE,
lines_connecting_means = TRUE,
line_colors = NULL,
line_types = NULL,
line_thickness = 1,
line_size = NULL,
dot_size = 3,
position_dodge = 0.13,
x_axis_title = NULL,
y_axis_title = NULL,
y_axis_title_vjust = 0.85,
legend_title = NULL,
legend_position = "right"
)
Arguments
data |
a data object (a data frame or a data.table) |
dv_name |
name of the dependent variable |
iv_name |
name(s) of the independent variable(s). Up to two independent variables can be supplied. |
na.rm |
logical. If |
error_bar |
if |
error_bar_range |
width of the confidence or prediction interval
(default = 0.95 for 95 percent confidence or prediction interval).
This argument will not apply when |
error_bar_tip_width |
graphically, width of the segments at the end of error bars (default = 0.13) |
error_bar_thickness |
thickness of the error bars (default = 1) |
error_bar_caption |
should a caption be included to indicate the width of the error bars? (default = TRUE). |
lines_connecting_means |
logical. Should lines connecting means within each group be drawn? (default = TRUE) |
line_colors |
colors of the lines connecting means (default = NULL)
If the second IV has two levels, then by default,
|
line_types |
types of the lines connecting means (default = NULL)
If the second IV has two levels, then by default,
|
line_thickness |
thickness of the lines connecting group means (default = 1) |
line_size |
Deprecated. Use the 'linewidth' argument instead. (default = 1) |
dot_size |
size of the dots indicating group means (default = 3) |
position_dodge |
by how much should the group means and error bars be horizontally offset from each other so as not to overlap? (default = 0.13) |
x_axis_title |
a character string for the x-axis title. If no
input is entered, then, by default, the first value of
|
y_axis_title |
a character string for the y-axis title. If no
input is entered, then, by default, |
y_axis_title_vjust |
position of the y axis title (default = 0.85).
By default, |
legend_title |
a character for the legend title. If no input
is entered, then, by default, the second value of |
legend_position |
position of the legend:
|
Value
by default, the output will be a ggplot object.
If output = "table"
, the output will be a data.table object.
Examples
plot_group_means(data = mtcars, dv_name = "mpg", iv_name = c("vs", "am"))
plot_group_means(
data = mtcars, dv_name = "mpg", iv_name = c("vs", "am"),
error_bar = "se"
)
plot_group_means(
data = mtcars, dv_name = "mpg", iv_name = c("vs", "am"),
error_bar = "pi", error_bar_range = 0.99
)
# set line colors and types manually
plot_group_means(
data = mtcars, dv_name = "mpg", iv_name = c("vs", "am"),
line_colors = c("green4", "purple"),
line_types = c("solid", "solid"))
# remove axis titles
plot_group_means(
data = mtcars, dv_name = "mpg", iv_name = c("vs", "am"),
x_axis_title = FALSE, y_axis_title = FALSE, legend_title = FALSE)