Learn R Programming

tna (version 1.0.0)

plot_frequencies.group_tna: Plot the Frequency Distribution of States

Description

Plot the Frequency Distribution of States

Usage

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

Value

A ggplot object.

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.

See Also

Basic functions build_model(), hist.group_tna(), hist.tna(), plot.group_tna(), plot.tna(), plot_frequencies(), plot_mosaic(), plot_mosaic.group_tna(), plot_mosaic.tna_data(), print.group_tna(), print.summary.group_tna(), print.summary.tna(), print.tna(), summary.group_tna(), summary.tna(), tna-package

Examples

Run this code
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)

Run the code above in your browser using DataLab