plot_group_means: Plot group means

Description Usage Arguments Value Examples

View source: R/plot_group_means.R

Description

Creates a plot of sample means and error bars by group.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
plot_group_means(
  data = NULL,
  dv_name = NULL,
  iv_name = NULL,
  na.rm = TRUE,
  error_bar = "ci",
  error_bar_range = 0.95,
  lines_connecting_means = TRUE,
  line_size = 1,
  dot_size = 3,
  error_bar_tip_width = 0.13,
  error_bar_thickness = 1,
  position_dodge = 0.13,
  legend_position = "right",
  y_axis_title_vjust = 0.85
)

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 na.rm = TRUE, NA values in independent and dependent variables will be removed before calculating group means.

error_bar

if error_bar = "se"; error bars will be +/-1 standard error, if error_bar = "ci" error bars will be a confidence interval; if error_bar = "pi", error bars will be a prediction interval

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 = "se"

lines_connecting_means

logical. Should lines connecting means within each group be drawn? (default = TRUE)

line_size

thickness of the lines connecting group means, (default = 1)

dot_size

size of the dots indicating group means (default = 3)

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)

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)

legend_position

position of the legend: "none", "top", "right", "bottom", "left", "none" (default = "right")

y_axis_title_vjust

position of the y axis title (default = 0.85). If default is used, y_axis_title_vjust = 0.85, the y axis title will be positioned at 85% of the way up from the bottom of the plot.

Value

by default, the output will be a ggplot object. If output = "table", the output will be a data.table object.

Examples

1
2
3
4
5
6
7
8
9
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
)

kim documentation built on April 25, 2021, 1:06 a.m.