Learn R Programming

ggstatsplot (version 0.7.2)

centrality_ggrepel: Adding labels for mean values.

Description

Adding labels for mean values.

Usage

centrality_ggrepel(
  plot,
  data,
  x,
  y,
  type = "parametric",
  tr = 0.2,
  k = 2L,
  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. Other data types (e.g., matrix,table, array, etc.) will not be accepted.

x

The grouping (or independent) variable from the dataframe data.

y

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

type

A character specifying the type of statistical approach. Four possible options:

  • "parametric"

  • "nonparametric"

  • "robust"

  • "bayes"

Corresponding abbreviations are also accepted: "p" (for parametric), "np" (for nonparametric), "r" (for robust), or "bf" (for Bayesian).

tr

Trim level for the mean when carrying out robust tests. In case of an error, try reducing the value of tr, which is by default set to 0.2. Lowering the value might help.

k

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

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

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

Run the code above in your browser using DataLab