Skip to contents

Plot the Frequency Distribution of States

Usage

# S3 method for class 'group_tna'
plot_frequencies(
  x,
  label,
  colors,
  width = 0.7,
  palette = "Set2",
  show_label = TRUE,
  position = "dodge",
  hjust = 1.2,
  ...
)

Arguments

x

A group_tna object.

label

An optional character string that can be provided to specify the grouping factor name if x was not constructed using a column name of the original data.

colors

A vector of colors to be used in the plot (one per group)

width

Width of the bars. Default is 0.7.

palette

A palette to be used if colors are not passed.

show_label

Boolean indicating whether to show a label with the frequency counts. Default is TRUE.

position

Position of the bars: "dodge", "dodge2", "fill" or "stack"

hjust

Horizontal adjustment of the labels. Default is 1.2.

...

Ignored.

Value

A ggplot object.

Examples

model <- group_model(engagement_mmm)
# Default
plot_frequencies(model)

# Default labels outside and custom colors
plot_frequencies(
  model,
  width = 0.9,
  hjust = -0.3,
  colors = c("#218516", "#f9c22e", "#53b3cb")
)

# Stacked with no labels
plot_frequencies(model, position = "stack", show_label = FALSE)

# Fill
plot_frequencies(model, position = "fill", hjust = 1.1)