Learn R Programming

ggstatsplot (version 0.5.0)

mean_ggrepel: Adding labels for mean values.

Description

Adding labels for mean values.

Usage

mean_ggrepel(
  plot,
  x,
  y,
  mean.data,
  mean.point.args = list(size = 5, color = "darkred"),
  mean.label.args = list(size = 3),
  inherit.aes = TRUE,
  ...
)

Arguments

plot

A ggplot object for which means are to be displayed.

x

The grouping variable from the dataframe data.

y

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

mean.data

A dataframe containing means for each level of the factor. The columns should be titled x, y, and label.

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.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders.

...

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()

# get a dataframe with means
mean_dat <- ggstatsplot:::mean_labeller(
  data = iris,
  x = Species,
  y = Sepal.Length,
  mean.ci = TRUE,
  k = 3
)

# add means
ggstatsplot:::mean_ggrepel(
  plot = p,
  x = Species,
  y = Sepal.Length,
  mean.data = mean_dat,
  mean.color = "darkgreen"
)
# }

Run the code above in your browser using DataLab