Learn R Programming

ggstatsplot (version 0.6.5)

mean_ggrepel: Adding labels for mean values.

Description

Adding labels for mean values.

Usage

mean_ggrepel(
  plot,
  data,
  x,
  y,
  mean.ci = FALSE,
  k = 3L,
  sample.size.label = TRUE,
  mean.path = FALSE,
  mean.path.args = list(color = "red", size = 1, alpha = 0.5),
  mean.point.args = list(size = 5, color = "darkred"),
  mean.label.args = list(size = 3),
  ...
)

Arguments

plot

A ggplot object for which means are to be displayed.

data

A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted.

x

The grouping variable from the dataframe data.

y

The response (a.k.a. outcome or dependent) variable from the dataframe data.

mean.ci

Logical that decides whether 95% confidence interval for mean is to be displayed (Default: FALSE).

k

Number of digits after decimal point (should be an integer) (Default: k = 2L).

sample.size.label

Logical that decides whether sample size information should be displayed for each level of the grouping variable x (Default: TRUE).

mean.path

Logical that decides whether individual data points and means, respectively, should be connected using geom_path. Both default to TRUE. Note that point.path argument is relevant only when there are two groups (i.e., in case of a t-test). In case of large number of data points, it is advisable to set point.path = FALSE as these lines can overwhelm the plot.

mean.path.args

A list of additional aesthetic arguments passed on to geom_path connecting raw data points and mean points.

mean.point.args

A list of additional aesthetic arguments to be passed to ggplot2::geom_point and ggrepel::geom_label_repel geoms involved mean value plotting.

mean.label.args

A list of additional aesthetic arguments to be passed to ggplot2::geom_point and ggrepel::geom_label_repel geoms involved mean value plotting.

...

Additional arguments.

Examples

Run this code
# NOT RUN {
# this internal function may not have much utility outside of the package
set.seed(123)
library(ggplot2)

# make a plot
p <- ggplot(data = iris, aes(x = Species, y = Sepal.Length)) +
  geom_boxplot()

# add means
ggstatsplot:::mean_ggrepel(
  data = iris,
  plot = p,
  x = Species,
  y = Sepal.Length
)
# }

Run the code above in your browser using DataLab