Adding labels for mean values.

centrality_ggrepel(
  plot,
  data,
  x,
  y,
  type = "parametric",
  tr = 0.1,
  k = 2L,
  sample.size.label = TRUE,
  centrality.path = FALSE,
  centrality.path.args = list(color = "red", size = 1, alpha = 0.5),
  centrality.point.args = list(size = 5, color = "darkred"),
  centrality.label.args = list(size = 3, nudge_x = 0.4, segment.linetype = 4),
  ...
)

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.

type

Type of statistic expected ("parametric" or "nonparametric" or "robust" or "bayes").Corresponding abbreviations are also accepted: "p" (for parametric), "np" (nonparametric), "r" (robust), or "bf"resp.

tr

Trim level for the mean when carrying out robust tests. If you get error stating "Standard error cannot be computed because of Winsorized variance of 0 (e.g., due to ties). Try to decrease the trimming level.", try to play around with the value of tr, which is by default set to 0.1. Lowering the value might help.

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

centrality.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.

centrality.path.args

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

centrality.point.args

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

centrality.label.args

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

...

Additional arguments.

Examples

# 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:::centrality_ggrepel( data = iris, plot = p, x = Species, y = Sepal.Length )