Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

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
)

ggstatsplot

'ggplot2' Based Plots with Statistical Details

v0.7.2
GPL-3 | file LICENSE
Authors
Indrajeet Patil [cre, aut, cph] (<https://orcid.org/0000-0003-1995-6531>, @patilindrajeets)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.