Learn R Programming

flashlight (version 0.8.0)

plot_counts: Add Counts to Effects Plot

Description

Add counts as labelled bar plot on top of light_effects plot.

Usage

plot_counts(
  p,
  x,
  text_size = 3,
  facet_scales = "free_x",
  show_labels = TRUE,
  big.mark = "'",
  scientific = FALSE,
  digits = 0,
  ...
)

Value

An object of class ggplot2.

Arguments

p

The result of plot.light_effects.

x

An object of class light_effects.

text_size

Size of count labels.

facet_scales

Scales argument passed to facet_wrap.

show_labels

Should count labels be added as text?

big.mark

Parameter passed to format the labels. Default is "'".

scientific

Parameter passed to format the labels. Default is FALSE.

digits

Used to round the labels. Default is 0.

...

Further arguments passed to geom_bar.

Details

Experimental. Uses package ggpubr to rearrange the figure. Thus, the resulting plot cannot be easily modified. Furthermore, adding counts only works if the legend in plot.light_effects is not placed on the left or right side of the plot. It has to be placed inside or at the bottom.

See Also

plot.light_effects.

Examples

Run this code
fit <- lm(Sepal.Length ~ ., data = iris)
fl <- flashlight(model = fit, label = "iris", data = iris, y = "Sepal.Length")
x <- light_effects(fl, v = "Species")
plot_counts(plot(x), x, width = 0.3, alpha = 0.2)

Run the code above in your browser using DataLab