ggstatsplot (version 0.7.2)

histo_labeller: Custom function for adding labeled lines for x-axis variable.

Description

Helper function for adding centrality parameter value and/or a test value for the continuous, numeric x-axis variable.

Usage

histo_labeller(
  plot,
  x,
  type = "parametric",
  tr = 0.2,
  k = 2L,
  centrality.line.args = list(color = "blue", size = 1),
  ...
)

Arguments

plot

A ggplot object for which the labeled lines need to be added for a test value and/or a centrality parameter (mean/median) value.

x

A numeric 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.line.args

A list of additional aesthetic arguments to be passed to the geom_line used to display the lines corresponding to the centrality parameter.

...

Currently ignored.

Examples

Run this code
# NOT RUN {
library(ggplot2)

# creating a plot; lines and labels will be superposed on this plot
p <- ggplot(mtcars, aes(wt, mpg)) +
  geom_point()

# adding labels
ggstatsplot:::histo_labeller(
  plot = p,
  x = mtcars$wt
)
# }

Run the code above in your browser using DataLab