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

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

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

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.

centrality.k

Integer denoting the number of decimal places expected for centrality parameter label. (Default: 2L).

centrality.line.args, test.value.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 and test value.

centrality.label.args, test.value.label.args

A list of additional aesthetic arguments to be passed to the geom_label used to display the label corresponding to the centrality parameter and test value.

...

Currently ignored.

Examples

# \donttest{ library(ggplot2) # creating a plot; lines and labels will be superposed on this plot p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() # computing `y`-axis positions for line labels y_label_pos <- median( x = ggplot2::layer_scales(p)$y$range$range, na.rm = TRUE ) # adding labels ggstatsplot:::histo_labeller( plot = p, x = mtcars$wt, y.label.position = y_label_pos, test.value.line = TRUE )
# }